1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
2 
foo()3 void foo() {
4 }
5 
foobool(int argc)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:
S2()16   S2() : a(0) {}
17 };
18 const S2 b;
19 const S2 ba[5];
20 class S3 {
21   int a;
22 
23 public:
S3()24   S3() : a(0) {}
25 };
26 const S3 ca[5];
27 class S4 {
28   int a;
29   S4(); // expected-note {{implicitly declared private here}}
30 
31 public:
S4(int v)32   S4(int v) : a(v) {}
33 };
34 class S5 {
35   int a;
S5()36   S5() : a(0) {} // expected-note {{implicitly declared private here}}
37 
38 public:
S5(int v)39   S5(int v) : a(v) {}
40 };
41 
42 S3 h;
43 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
44 
45 template <class I, class C>
foomain(I argc,C ** argv)46 int foomain(I argc, C **argv) {
47   I e(4);
48   I g(5);
49   int i;
50   int &j = i;                // expected-note {{'j' defined here}}
51 #pragma omp single private // expected-error {{expected '(' after 'private'}}
52   foo();
53 #pragma omp single private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
54   foo();
55 #pragma omp single private() // expected-error {{expected expression}}
56   foo();
57 #pragma omp single private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
58   foo();
59 #pragma omp single private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
60   foo();
61 #pragma omp single private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
62   foo();
63 #pragma omp single private(argc)
64   foo();
65 #pragma omp single private(S1) // expected-error {{'S1' does not refer to a value}}
66   foo();
67 #pragma omp single private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
68   foo();
69 #pragma omp single private(argv[1]) // expected-error {{expected variable name}}
70   foo();
71 #pragma omp single private(e, g)
72   foo();
73 #pragma omp single private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
74   foo();
75 #pragma omp single shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp single'}}
76   foo();
77 #pragma omp parallel
78   {
79     int v = 0;
80     int i;
81 #pragma omp single private(i)
82     foo();
83     v += i;
84   }
85 #pragma omp parallel shared(i)
86 #pragma omp parallel private(i)
87 #pragma omp single private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
88   foo();
89 #pragma omp single private(i)
90   foo();
91   return 0;
92 }
93 
94 namespace A {
95 double x;
96 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
97 }
98 namespace B {
99 using A::x;
100 }
101 
main(int argc,char ** argv)102 int main(int argc, char **argv) {
103   S4 e(4);
104   S5 g(5);
105   int i;
106   int &j = i;                // expected-note {{'j' defined here}}
107 #pragma omp single private // expected-error {{expected '(' after 'private'}}
108   foo();
109 #pragma omp single private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
110   foo();
111 #pragma omp single private() // expected-error {{expected expression}}
112   foo();
113 #pragma omp single private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
114   foo();
115 #pragma omp single private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
116   foo();
117 #pragma omp single private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
118   foo();
119 #pragma omp single private(argc)
120   foo();
121 #pragma omp single private(S1) // expected-error {{'S1' does not refer to a value}}
122   foo();
123 #pragma omp single private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
124   foo();
125 #pragma omp single private(argv[1]) // expected-error {{expected variable name}}
126   foo();
127 #pragma omp single private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
128   foo();
129 #pragma omp single private(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}}
130   foo();
131 #pragma omp single shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp single'}}
132   foo();
133 #pragma omp parallel
134   {
135     int i;
136 #pragma omp single private(i)
137     foo();
138   }
139 #pragma omp parallel shared(i)
140 #pragma omp parallel private(i)
141 #pragma omp single private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
142   foo();
143 #pragma omp single private(i)
144   foo();
145 
146   return 0;
147 }
148 
149