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
main(int argc,char ** argv)94 int main(int argc, char **argv) {
95 S4 e(4);
96 S5 g(5);
97 int i;
98 int &j = i; // expected-note {{'j' defined here}}
99 #pragma omp single private // expected-error {{expected '(' after 'private'}}
100 foo();
101 #pragma omp single private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
102 foo();
103 #pragma omp single private() // expected-error {{expected expression}}
104 foo();
105 #pragma omp single private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
106 foo();
107 #pragma omp single private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
108 foo();
109 #pragma omp single private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
110 foo();
111 #pragma omp single private(argc)
112 foo();
113 #pragma omp single private(S1) // expected-error {{'S1' does not refer to a value}}
114 foo();
115 #pragma omp single private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
116 foo();
117 #pragma omp single private(argv[1]) // expected-error {{expected variable name}}
118 foo();
119 #pragma omp single private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
120 foo();
121 #pragma omp single private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
122 foo();
123 #pragma omp single shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp single'}}
124 foo();
125 #pragma omp parallel
126 {
127 int i;
128 #pragma omp single private(i)
129 foo();
130 }
131 #pragma omp parallel shared(i)
132 #pragma omp parallel private(i)
133 #pragma omp single private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
134 foo();
135 #pragma omp single private(i)
136 foo();
137
138 return 0;
139 }
140
141