Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %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   T i;
     15 #pragma omp target
     16 #pragma omp teams
     17 #pragma omp distribute parallel for if // expected-error {{expected '(' after 'if'}}
     18   for (i = 0; i < argc; ++i) foo();
     19 #pragma omp target
     20 #pragma omp teams
     21 #pragma omp distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     22   for (i = 0; i < argc; ++i) foo();
     23 #pragma omp target
     24 #pragma omp teams
     25 #pragma omp distribute parallel for if () // expected-error {{expected expression}}
     26   for (i = 0; i < argc; ++i) foo();
     27 #pragma omp target
     28 #pragma omp teams
     29 #pragma omp distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     30   for (i = 0; i < argc; ++i) foo();
     31 #pragma omp target
     32 #pragma omp teams
     33 #pragma omp distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
     34   for (i = 0; i < argc; ++i) foo();
     35 #pragma omp target
     36 #pragma omp teams
     37 #pragma omp distribute parallel for if (argc > 0 ? argv[1] : argv[2])
     38   for (i = 0; i < argc; ++i) foo();
     39 #pragma omp target
     40 #pragma omp teams
     41 #pragma omp distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause}}
     42   for (i = 0; i < argc; ++i) foo();
     43 #pragma omp target
     44 #pragma omp teams
     45 #pragma omp distribute parallel for if (S) // expected-error {{'S' does not refer to a value}}
     46   for (i = 0; i < argc; ++i) foo();
     47 #pragma omp target
     48 #pragma omp teams
     49 #pragma omp distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     50   for (i = 0; i < argc; ++i) foo();
     51 #pragma omp target
     52 #pragma omp teams
     53 #pragma omp distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     54   for (i = 0; i < argc; ++i) foo();
     55 #pragma omp target
     56 #pragma omp teams
     57 #pragma omp distribute parallel for if(argc)
     58   for (i = 0; i < argc; ++i) foo();
     59 #pragma omp target
     60 #pragma omp teams
     61 #pragma omp distribute parallel for if(parallel // expected-warning {{missing ':' after directive name modifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     62   for (i = 0; i < argc; ++i) foo();
     63 #pragma omp target
     64 #pragma omp teams
     65 #pragma omp distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     66   for (i = 0; i < argc; ++i) foo();
     67 #pragma omp target
     68 #pragma omp teams
     69 #pragma omp distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     70   for (i = 0; i < argc; ++i) foo();
     71 #pragma omp target
     72 #pragma omp teams
     73 #pragma omp distribute parallel for if(parallel : argc)
     74   for (i = 0; i < argc; ++i) foo();
     75 #pragma omp target
     76 #pragma omp teams
     77 #pragma omp distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp distribute parallel for'}}
     78   for (i = 0; i < argc; ++i) foo();
     79 #pragma omp target
     80 #pragma omp teams
     81 #pragma omp distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
     82   for (i = 0; i < argc; ++i) foo();
     83 #pragma omp target
     84 #pragma omp teams
     85 #pragma omp distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
     86   for (i = 0; i < argc; ++i) foo();
     87 #pragma omp target
     88 #pragma omp teams
     89 #pragma omp distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp distribute parallel for'}}
     90   for (i = 0; i < argc; ++i) foo();
     91 
     92   return 0;
     93 }
     94 
     95 int main(int argc, char **argv) {
     96   int i;
     97 #pragma omp target
     98 #pragma omp teams
     99 #pragma omp distribute parallel for if // expected-error {{expected '(' after 'if'}}
    100   for (i = 0; i < argc; ++i) foo();
    101 #pragma omp target
    102 #pragma omp teams
    103 #pragma omp distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    104   for (i = 0; i < argc; ++i) foo();
    105 #pragma omp target
    106 #pragma omp teams
    107 #pragma omp distribute parallel for if () // expected-error {{expected expression}}
    108   for (i = 0; i < argc; ++i) foo();
    109 #pragma omp target
    110 #pragma omp teams
    111 #pragma omp distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
    112   for (i = 0; i < argc; ++i) foo();
    113 #pragma omp target
    114 #pragma omp teams
    115 #pragma omp distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
    116   for (i = 0; i < argc; ++i) foo();
    117 #pragma omp target
    118 #pragma omp teams
    119 #pragma omp distribute parallel for if (argc > 0 ? argv[1] : argv[2])
    120   for (i = 0; i < argc; ++i) foo();
    121 #pragma omp target
    122 #pragma omp teams
    123 #pragma omp distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause}}
    124   for (i = 0; i < argc; ++i) foo();
    125 #pragma omp target
    126 #pragma omp teams
    127 #pragma omp distribute parallel for if (S1) // expected-error {{'S1' does not refer to a value}}
    128   for (i = 0; i < argc; ++i) foo();
    129 #pragma omp target
    130 #pragma omp teams
    131 #pragma omp distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
    132   for (i = 0; i < argc; ++i) foo();
    133 #pragma omp target
    134 #pragma omp teams
    135 #pragma omp distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
    136   for (i = 0; i < argc; ++i) foo();
    137 #pragma omp target
    138 #pragma omp teams
    139 #pragma omp distribute parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
    140   for (i = 0; i < argc; ++i) foo();
    141 #pragma omp target
    142 #pragma omp teams
    143 #pragma omp distribute parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    144   for (i = 0; i < argc; ++i) foo();
    145 #pragma omp target
    146 #pragma omp teams
    147 #pragma omp distribute parallel for if(parallel // expected-warning {{missing ':' after directive name modifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    148   for (i = 0; i < argc; ++i) foo();
    149 #pragma omp target
    150 #pragma omp teams
    151 #pragma omp distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    152   for (i = 0; i < argc; ++i) foo();
    153 #pragma omp target
    154 #pragma omp teams
    155 #pragma omp distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
    156   for (i = 0; i < argc; ++i) foo();
    157 #pragma omp target
    158 #pragma omp teams
    159 #pragma omp distribute parallel for if(parallel : argc)
    160   for (i = 0; i < argc; ++i) foo();
    161 #pragma omp target
    162 #pragma omp teams
    163 #pragma omp distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp distribute parallel for'}}
    164   for (i = 0; i < argc; ++i) foo();
    165 #pragma omp target
    166 #pragma omp teams
    167 #pragma omp distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
    168   for (i = 0; i < argc; ++i) foo();
    169 #pragma omp target
    170 #pragma omp teams
    171 #pragma omp distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
    172   for (i = 0; i < argc; ++i) foo();
    173 #pragma omp target
    174 #pragma omp teams
    175 #pragma omp distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp distribute parallel for'}}
    176   for (i = 0; i < argc; ++i) foo();
    177 
    178   return tmain(argc, argv);
    179 }
    180