Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
      2 
      3 void foo() {
      4 }
      5 
      6 bool foobool(int argc) {
      7   return argc;
      8 }
      9 
     10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
     11 extern S1 a;
     12 class S2 {
     13   mutable int a;
     14 
     15 public:
     16   S2() : a(0) {}
     17   S2(S2 &s2) : a(s2.a) {}
     18   static float S2s; // expected-note {{static data member is predetermined as shared}}
     19   static const float S2sc;
     20 };
     21 const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
     22 const S2 b;
     23 const S2 ba[5];
     24 class S3 { // expected-note 2 {{'S3' declared here}}
     25   int a;
     26   S3 &operator=(const S3 &s3);
     27 
     28 public:
     29   S3() : a(0) {}
     30   S3(S3 &s3) : a(s3.a) {}
     31 };
     32 const S3 c;         // expected-note {{global variable is predetermined as shared}}
     33 const S3 ca[5];     // expected-note {{global variable is predetermined as shared}}
     34 extern const int f; // expected-note {{global variable is predetermined as shared}}
     35 class S4 {          // expected-note 3 {{'S4' declared here}}
     36   int a;
     37   S4();
     38   S4(const S4 &s4);
     39 
     40 public:
     41   S4(int v) : a(v) {}
     42 };
     43 class S5 { // expected-note {{'S5' declared here}}
     44   int a;
     45   S5() : a(0) {}
     46 
     47 public:
     48   S5(const S5 &s5) : a(s5.a) {}
     49   S5(int v) : a(v) {}
     50 };
     51 class S6 {
     52   int a;
     53   S6() : a(0) {}
     54 
     55 public:
     56   S6(const S6 &s6) : a(s6.a) {}
     57   S6(int v) : a(v) {}
     58 };
     59 
     60 S3 h;
     61 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
     62 
     63 template <class I, class C>
     64 int foomain(int argc, char **argv) {
     65   I e(4); // expected-note {{'e' defined here}}
     66   I g(5); // expected-note {{'g' defined here}}
     67   int i;
     68   int &j = i;                             // expected-note {{'j' defined here}}
     69 #pragma omp parallel sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
     70   {
     71     foo();
     72   }
     73 #pragma omp parallel sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     74   {
     75     foo();
     76   }
     77 #pragma omp parallel sections lastprivate() // expected-error {{expected expression}}
     78   {
     79     foo();
     80   }
     81 #pragma omp parallel sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     82   {
     83     foo();
     84   }
     85 #pragma omp parallel sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     86   {
     87     foo();
     88   }
     89 #pragma omp parallel sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
     90   {
     91     foo();
     92   }
     93 #pragma omp parallel sections lastprivate(argc)
     94   {
     95     foo();
     96   }
     97 #pragma omp parallel sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
     98   {
     99     foo();
    100   }
    101 #pragma omp parallel sections lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
    102   {
    103     foo();
    104   }
    105 #pragma omp parallel sections lastprivate(argv[1]) // expected-error {{expected variable name}}
    106   {
    107     foo();
    108   }
    109 #pragma omp parallel sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
    110   {
    111     foo();
    112   }
    113 #pragma omp parallel sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
    114   {
    115     foo();
    116   }
    117 #pragma omp parallel sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}}
    118   {
    119     foo();
    120   }
    121 #pragma omp parallel
    122   {
    123     int v = 0;
    124     int i;
    125 #pragma omp parallel sections lastprivate(i)
    126     {
    127       foo();
    128     }
    129     v += i;
    130   }
    131 #pragma omp parallel shared(i)
    132 #pragma omp parallel private(i)
    133 #pragma omp parallel sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
    134   {
    135     foo();
    136   }
    137 #pragma omp parallel sections lastprivate(i)
    138   {
    139     foo();
    140   }
    141   return 0;
    142 }
    143 
    144 int main(int argc, char **argv) {
    145   const int d = 5;       // expected-note {{constant variable is predetermined as shared}}
    146   const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
    147   S4 e(4);               // expected-note {{'e' defined here}}
    148   S5 g(5);               // expected-note {{'g' defined here}}
    149   S3 m;                  // expected-note 2 {{'m' defined here}}
    150   S6 n(2);
    151   int i;
    152   int &j = i;                             // expected-note {{'j' defined here}}
    153 #pragma omp parallel sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
    154   {
    155     foo();
    156   }
    157 #pragma omp parallel sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    158   {
    159     foo();
    160   }
    161 #pragma omp parallel sections lastprivate() // expected-error {{expected expression}}
    162   {
    163     foo();
    164   }
    165 #pragma omp parallel sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
    166   {
    167     foo();
    168   }
    169 #pragma omp parallel sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    170   {
    171     foo();
    172   }
    173 #pragma omp parallel sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
    174   {
    175     foo();
    176   }
    177 #pragma omp parallel sections lastprivate(argc)
    178   {
    179     foo();
    180   }
    181 #pragma omp parallel sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
    182   {
    183     foo();
    184   }
    185 #pragma omp parallel sections lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
    186   {
    187     foo();
    188   }
    189 #pragma omp parallel sections lastprivate(argv[1]) // expected-error {{expected variable name}}
    190   {
    191     foo();
    192   }
    193 #pragma omp parallel sections lastprivate(2 * 2) // expected-error {{expected variable name}}
    194   {
    195     foo();
    196   }
    197 #pragma omp parallel sections lastprivate(ba)
    198   {
    199     foo();
    200   }
    201 #pragma omp parallel sections lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
    202   {
    203     foo();
    204   }
    205 #pragma omp parallel sections lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
    206   {
    207     foo();
    208   }
    209   int xa;
    210 #pragma omp parallel sections lastprivate(xa) // OK
    211   {
    212     foo();
    213   }
    214 #pragma omp parallel sections lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
    215   {
    216     foo();
    217   }
    218 #pragma omp parallel sections lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
    219   {
    220     foo();
    221   }
    222 #pragma omp parallel sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel sections'}}
    223   {
    224     foo();
    225   }
    226 #pragma omp parallel sections lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
    227   {
    228     foo();
    229   }
    230 #pragma omp parallel sections lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
    231   {
    232     foo();
    233   }
    234 #pragma omp parallel sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
    235   {
    236     foo();
    237   }
    238 #pragma omp parallel sections private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
    239   {
    240     foo();
    241   }
    242 #pragma omp parallel sections lastprivate(i)
    243   {
    244     foo();
    245   }
    246 #pragma omp parallel private(xa)
    247 #pragma omp parallel sections lastprivate(xa)
    248   {
    249     foo();
    250   }
    251 #pragma omp parallel reduction(+ : xa)
    252 #pragma omp parallel sections lastprivate(xa)
    253   {
    254     foo();
    255   }
    256 #pragma omp parallel sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
    257   {
    258     foo();
    259   }
    260 #pragma omp parallel sections firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
    261   {
    262     foo();
    263   }
    264 #pragma omp parallel sections lastprivate(n) firstprivate(n) // OK
    265   {
    266     foo();
    267   }
    268   return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
    269 }
    270