Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
      2 
      3 void foo() {
      4 }
      5 
      6 struct S1; // expected-note 2 {{declared here}}
      7 class S2 {
      8   mutable int a;
      9 
     10 public:
     11   S2() : a(0) {}
     12   S2 &operator=(S2 &s2) { return *this; }
     13 };
     14 class S3 {
     15   int a;
     16 
     17 public:
     18   S3() : a(0) {}
     19   S3 &operator=(S3 &s3) { return *this; }
     20 };
     21 class S4 { // expected-note 2 {{'S4' declared here}}
     22   int a;
     23   S4();
     24   S4 &operator=(const S4 &s4);
     25 
     26 public:
     27   S4(int v) : a(v) {}
     28 };
     29 class S5 { // expected-note 2 {{'S5' declared here}}
     30   int a;
     31   S5() : a(0) {}
     32   S5 &operator=(const S5 &s5) { return *this; }
     33 
     34 public:
     35   S5(int v) : a(v) {}
     36 };
     37 
     38 S2 k;
     39 S3 h;
     40 S4 l(3); // expected-note 2 {{'l' defined here}}
     41 S5 m(4); // expected-note 2 {{'m' defined here}}
     42 #pragma omp threadprivate(h, k, l, m)
     43 
     44 template <class T, class C>
     45 T tmain(T argc, C **argv) {
     46   T i;
     47 #pragma omp parallel
     48 #pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
     49 #pragma omp parallel
     50 #pragma omp single copyprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     51 #pragma omp parallel
     52 #pragma omp single copyprivate() // expected-error {{expected expression}}
     53 #pragma omp parallel
     54 #pragma omp single copyprivate(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
     55 #pragma omp parallel
     56 #pragma omp single copyprivate(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     57 #pragma omp parallel
     58 #pragma omp single copyprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
     59 #pragma omp parallel
     60 #pragma omp single copyprivate(l) // expected-error {{copyprivate variable must have an accessible, unambiguous copy assignment operator}}
     61 #pragma omp parallel
     62 #pragma omp single copyprivate(S1) // expected-error {{'S1' does not refer to a value}}
     63 #pragma omp parallel
     64 #pragma omp single copyprivate(argv[1]) // expected-error {{expected variable name}}
     65 #pragma omp parallel // expected-note {{implicitly determined as shared}}
     66 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
     67 #pragma omp parallel
     68 #pragma omp single copyprivate(m) // expected-error {{copyprivate variable must have an accessible, unambiguous copy assignment operator}}
     69   foo();
     70 #pragma omp parallel private(i)
     71   {
     72 #pragma omp single copyprivate(i)
     73     foo();
     74   }
     75 #pragma omp parallel shared(i) // expected-note {{defined as shared}}
     76   {
     77 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
     78     foo();
     79   }
     80 #pragma omp parallel private(i)
     81 #pragma omp parallel default(shared) // expected-note {{implicitly determined as shared}}
     82   {
     83 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
     84     foo();
     85   }
     86 #pragma omp parallel private(i)
     87 #pragma omp parallel // expected-note {{implicitly determined as shared}}
     88   {
     89 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
     90     foo();
     91   }
     92 #pragma omp parallel
     93 #pragma omp single private(i) copyprivate(i) // expected-error {{private variable cannot be copyprivate}} expected-note {{defined as private}}
     94   foo();
     95 #pragma omp parallel
     96 #pragma omp single firstprivate(i) copyprivate(i) // expected-error {{firstprivate variable cannot be copyprivate}} expected-note {{defined as firstprivate}}
     97   foo();
     98 
     99   return T();
    100 }
    101 
    102 int main(int argc, char **argv) {
    103   int i;
    104 #pragma omp parallel
    105 #pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
    106 #pragma omp parallel
    107 #pragma omp single copyprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    108 #pragma omp parallel
    109 #pragma omp single copyprivate() // expected-error {{expected expression}}
    110 #pragma omp parallel
    111 #pragma omp single copyprivate(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
    112 #pragma omp parallel
    113 #pragma omp single copyprivate(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    114 #pragma omp parallel
    115 #pragma omp single copyprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
    116 #pragma omp parallel
    117 #pragma omp single copyprivate(l) // expected-error {{copyprivate variable must have an accessible, unambiguous copy assignment operator}}
    118 #pragma omp parallel
    119 #pragma omp single copyprivate(S1) // expected-error {{'S1' does not refer to a value}}
    120 #pragma omp parallel
    121 #pragma omp single copyprivate(argv[1]) // expected-error {{expected variable name}}
    122 #pragma omp parallel // expected-note {{implicitly determined as shared}}
    123 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
    124 #pragma omp parallel
    125 #pragma omp single copyprivate(m) // expected-error {{copyprivate variable must have an accessible, unambiguous copy assignment operator}}
    126   foo();
    127 #pragma omp parallel private(i)
    128   {
    129 #pragma omp single copyprivate(i)
    130     foo();
    131   }
    132 #pragma omp parallel shared(i) // expected-note {{defined as shared}}
    133   {
    134 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
    135     foo();
    136   }
    137 #pragma omp parallel private(i)
    138 #pragma omp parallel default(shared) // expected-note {{implicitly determined as shared}}
    139   {
    140 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
    141     foo();
    142   }
    143 #pragma omp parallel private(i)
    144 #pragma omp parallel // expected-note {{implicitly determined as shared}}
    145   {
    146 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
    147     foo();
    148   }
    149 #pragma omp parallel
    150 #pragma omp single private(i) copyprivate(i) // expected-error {{private variable cannot be copyprivate}} expected-note {{defined as private}}
    151   foo();
    152 #pragma omp parallel
    153 #pragma omp single firstprivate(i) copyprivate(i) // expected-error {{firstprivate variable cannot be copyprivate}} expected-note {{defined as firstprivate}}
    154   foo();
    155 
    156   return tmain(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char>' requested here}}
    157 }
    158