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}} expected-note{{forward declaration of 'S1'}}
     11 extern S1 a;
     12 class S2 {
     13   mutable int a;
     14 
     15 public:
     16   S2() : a(0) {}
     17   S2(const S2 &s2) : a(s2.a) {}
     18   static float S2s;
     19   static const float S2sc;
     20 };
     21 const float S2::S2sc = 0;
     22 const S2 b;
     23 const S2 ba[5];
     24 class S3 {
     25   int a;
     26   S3 &operator=(const S3 &s3);
     27 
     28 public:
     29   S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
     30   S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
     31 };
     32 const S3 c;
     33 const S3 ca[5];
     34 extern const int f;
     35 class S4 {
     36   int a;
     37   S4();
     38   S4(const S4 &s4);
     39 public:
     40   S4(int v):a(v) { }
     41 };
     42 class S5 {
     43   int a;
     44   S5():a(0) {}
     45   S5(const S5 &s5):a(s5.a) { }
     46 public:
     47   S5(int v):a(v) { }
     48 };
     49 class S6 {
     50   int a;
     51 public:
     52   S6() : a(0) { }
     53 };
     54 
     55 S3 h;
     56 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
     57 
     58 int main(int argc, char **argv) {
     59   const int d = 5;
     60   const int da[5] = { 0 };
     61   S4 e(4);
     62   S5 g(5);
     63   S6 p;
     64   int i;
     65   int &j = i;
     66   #pragma omp distribute firstprivate // expected-error {{expected '(' after 'firstprivate'}}
     67   for (i = 0; i < argc; ++i) foo();
     68   #pragma omp distribute firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     69   for (i = 0; i < argc; ++i) foo();
     70   #pragma omp distribute firstprivate () // expected-error {{expected expression}}
     71   for (i = 0; i < argc; ++i) foo();
     72   #pragma omp target
     73   #pragma omp teams
     74   #pragma omp distribute firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
     75   for (i = 0; i < argc; ++i) foo();
     76   #pragma omp target
     77   #pragma omp teams
     78   #pragma omp distribute firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     79   for (i = 0; i < argc; ++i) foo();
     80   #pragma omp target
     81   #pragma omp teams
     82   #pragma omp distribute firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
     83   for (i = 0; i < argc; ++i) foo();
     84   #pragma omp target
     85   #pragma omp teams
     86   #pragma omp distribute firstprivate (argc)
     87   for (i = 0; i < argc; ++i) foo();
     88   #pragma omp target
     89   #pragma omp teams
     90   #pragma omp distribute firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
     91   for (i = 0; i < argc; ++i) foo();
     92   #pragma omp target
     93   #pragma omp teams
     94   #pragma omp distribute firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
     95   for (i = 0; i < argc; ++i) foo();
     96   #pragma omp target
     97   #pragma omp teams
     98   #pragma omp distribute firstprivate (argv[1]) // expected-error {{expected variable name}}
     99   for (i = 0; i < argc; ++i) foo();
    100   #pragma omp target
    101   #pragma omp teams
    102   #pragma omp distribute firstprivate(ba)
    103   for (i = 0; i < argc; ++i) foo();
    104   #pragma omp target
    105   #pragma omp teams
    106   #pragma omp distribute firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
    107   for (i = 0; i < argc; ++i) foo();
    108   #pragma omp target
    109   #pragma omp teams
    110   #pragma omp distribute firstprivate(da)
    111   for (i = 0; i < argc; ++i) foo();
    112   #pragma omp target
    113   #pragma omp teams
    114   #pragma omp distribute firstprivate(S2::S2s)
    115   for (i = 0; i < argc; ++i) foo();
    116   #pragma omp target
    117   #pragma omp teams
    118   #pragma omp distribute firstprivate(S2::S2sc)
    119   for (i = 0; i < argc; ++i) foo();
    120   #pragma omp target
    121   #pragma omp teams
    122   #pragma omp distribute firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
    123   for (i = 0; i < argc; ++i) foo();
    124   #pragma omp target
    125   #pragma omp teams
    126   #pragma omp distribute private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
    127   for (i = 0; i < argc; ++i) foo();
    128   #pragma omp target
    129   #pragma omp teams shared(i)
    130   #pragma omp distribute firstprivate(i)
    131   for (j = 0; j < argc; ++j) foo();
    132   #pragma omp target
    133   #pragma omp teams shared(i)
    134   #pragma omp distribute firstprivate(i) // expected-note {{defined as firstprivate}}
    135   for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp distribute' directive may not be firstprivate, predetermined as private}}
    136   #pragma omp target
    137   #pragma omp teams private(argc) // expected-note {{defined as private}}
    138   #pragma omp distribute firstprivate(argc) // expected-error {{private variable in '#pragma omp teams' cannot be firstprivate in '#pragma omp distribute'}}
    139   for (i = 0; i < argc; ++i) foo();
    140   #pragma omp target
    141   #pragma omp teams reduction(+:argc) // expected-note {{defined as reduction}}
    142   #pragma omp distribute firstprivate(argc) // expected-error {{reduction variable in '#pragma omp teams' cannot be firstprivate in '#pragma omp distribute'}}
    143   for (i = 0; i < argc; ++i) foo();
    144   #pragma omp target
    145   #pragma omp teams
    146   #pragma omp distribute firstprivate(j)
    147   for (i = 0; i < argc; ++i) foo();
    148   #pragma omp target
    149   #pragma omp teams
    150   #pragma omp distribute lastprivate(argc), firstprivate(argc) // expected-error {{lastprivate variable cannot be firstprivate in '#pragma omp distribute'}} expected-note{{defined as lastprivate}}
    151   for (i = 0; i < argc; ++i) foo();
    152   #pragma omp target
    153   #pragma omp teams
    154 #pragma omp distribute firstprivate(argc), lastprivate(argc)  // expected-error {{lastprivate variable cannot be firstprivate in '#pragma omp distribute'}} expected-note{{defined as firstprivate}}
    155   for (i = 0; i < argc; ++i) foo();
    156   return 0;
    157 }
    158