Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp %s
      2 
      3 void foo() {
      4 }
      5 
      6 bool foobool(int argc) {
      7   return argc;
      8 }
      9 
     10 struct S1; // expected-note {{declared here}}
     11 
     12 template <class T, class S> // expected-note {{declared here}}
     13 int tmain(T argc, S **argv) {
     14   int i;
     15   #pragma omp target parallel for if // expected-error {{expected '(' after 'if'}}
     16   for (i = 0; i < argc; ++i) foo();
     17   #pragma omp target parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     18   for (i = 0; i < argc; ++i) foo();
     19   #pragma omp target parallel for if () // expected-error {{expected expression}}
     20   for (i = 0; i < argc; ++i) foo();
     21   #pragma omp target parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     22   for (i = 0; i < argc; ++i) foo();
     23   #pragma omp target parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
     24   for (i = 0; i < argc; ++i) foo();
     25   #pragma omp target parallel for if (argc > 0 ? argv[1] : argv[2])
     26   for (i = 0; i < argc; ++i) foo();
     27   #pragma omp target parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause}}
     28   for (i = 0; i < argc; ++i) foo();
     29   #pragma omp target parallel for if (S) // expected-error {{'S' does not refer to a value}}
     30   for (i = 0; i < argc; ++i) foo();
     31   #pragma omp target parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     32   for (i = 0; i < argc; ++i) foo();
     33   #pragma omp target parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     34   for (i = 0; i < argc; ++i) foo();
     35   #pragma omp target parallel for if(argc)
     36   for (i = 0; i < argc; ++i) foo();
     37   #pragma omp target parallel for if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     38   for (i = 0; i < argc; ++i) foo();
     39   #pragma omp target parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     40   for (i = 0; i < argc; ++i) foo();
     41   #pragma omp target parallel for if(target : argc)
     42   for (i = 0; i < argc; ++i) foo();
     43   #pragma omp target parallel for if(parallel : argc)
     44   for (i = 0; i < argc; ++i) foo();
     45   #pragma omp target parallel for if(target : argc) if(parallel : argc)
     46   for (i = 0; i < argc; ++i) foo();
     47   #pragma omp target parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel for'}}
     48   for (i = 0; i < argc; ++i) foo();
     49   #pragma omp target parallel for if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'target' name modifier}}
     50   for (i = 0; i < argc; ++i) foo();
     51   #pragma omp target parallel for if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
     52   for (i = 0; i < argc; ++i) foo();
     53   #pragma omp target parallel for if(target : argc) if (argc) // expected-error {{expected  'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
     54   for (i = 0; i < argc; ++i) foo();
     55   #pragma omp target parallel for if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}}
     56   for (i = 0; i < argc; ++i) foo();
     57 
     58   return 0;
     59 }
     60 
     61 int main(int argc, char **argv) {
     62   int i;
     63   #pragma omp target parallel for if // expected-error {{expected '(' after 'if'}}
     64   for (i = 0; i < argc; ++i) foo();
     65   #pragma omp target parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     66   for (i = 0; i < argc; ++i) foo();
     67   #pragma omp target parallel for if () // expected-error {{expected expression}}
     68   for (i = 0; i < argc; ++i) foo();
     69   #pragma omp target parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     70   for (i = 0; i < argc; ++i) foo();
     71   #pragma omp target parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}}
     72   for (i = 0; i < argc; ++i) foo();
     73   #pragma omp target parallel for if (argc > 0 ? argv[1] : argv[2])
     74   for (i = 0; i < argc; ++i) foo();
     75   #pragma omp target parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause}}
     76   for (i = 0; i < argc; ++i) foo();
     77   #pragma omp target parallel for if (S1) // expected-error {{'S1' does not refer to a value}}
     78   for (i = 0; i < argc; ++i) foo();
     79   #pragma omp target parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     80   for (i = 0; i < argc; ++i) foo();
     81   #pragma omp target parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     82   for (i = 0; i < argc; ++i) foo();
     83   #pragma omp target parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     84   for (i = 0; i < argc; ++i) foo();
     85   #pragma omp target parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     86   for (i = 0; i < argc; ++i) foo();
     87   #pragma omp target parallel for if(target : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     88   for (i = 0; i < argc; ++i) foo();
     89   #pragma omp target parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     90   for (i = 0; i < argc; ++i) foo();
     91   #pragma omp target parallel for if(parallel : argc)
     92   for (i = 0; i < argc; ++i) foo();
     93   #pragma omp target parallel for if(target : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target parallel for'}}
     94   for (i = 0; i < argc; ++i) foo();
     95   #pragma omp target parallel for if(target : argc) if (target :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'target' name modifier}}
     96   for (i = 0; i < argc; ++i) foo();
     97   #pragma omp target parallel for if(parallel : argc) if (parallel :argc) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
     98   for (i = 0; i < argc; ++i) foo();
     99   #pragma omp target parallel for if(target : argc) if (argc) // expected-error {{expected  'parallel' directive name modifier}} expected-note {{previous clause with directive name modifier specified here}}
    100   for (i = 0; i < argc; ++i) foo();
    101   #pragma omp target parallel for if(target : argc) if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}} expected-note {{previous clause with directive name modifier specified here}}
    102   for (i = 0; i < argc; ++i) foo();
    103 
    104   return tmain(argc, argv);
    105 }
    106