blob: 02186e737b756ea6fee032661514b9609d512255 [file] [log] [blame]
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00003// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s
4
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00005void foo() {
6}
7
8bool foobool(int argc) {
9 return argc;
10}
11
12struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
13extern S1 a;
14class S2 {
15 mutable int a;
16public:
17 S2():a(0) { }
18 S2(const S2 &s2):a(s2.a) { }
19 static float S2s;
20 static const float S2sc;
21};
22const float S2::S2sc = 0;
23const S2 b;
24const S2 ba[5];
25class S3 {
26 int a;
27public:
28 S3():a(0) { }
29 S3(const S3 &s3):a(s3.a) { }
30};
31const S3 c;
32const S3 ca[5];
33extern const int f;
34class S4 {
35 int a;
36 S4();
37 S4(const S4 &s4); // expected-note {{implicitly declared private here}}
38public:
39 S4(int v):a(v) { }
40};
41class S5 {
42 int a;
43 S5():a(0) {}
44 S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}}
45public:
46 S5(int v):a(v) { }
47};
48
49S3 h;
50#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
51
52namespace A {
53double x;
54#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
55}
56namespace B {
57using A::x;
58}
59
60int main(int argc, char **argv) {
61 const int d = 5;
62 const int da[5] = { 0 };
63 S4 e(4);
64 S5 g(5);
65 int i;
66 int &j = i;
67 static int m;
68 #pragma omp target parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000069 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000070 #pragma omp target parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000071 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000072 #pragma omp target parallel firstprivate () // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000073 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000074 #pragma omp target parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000075 foo();
Alexey Bataevc5970622016-04-01 08:43:42 +000076 #pragma omp target parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000077 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000078 #pragma omp target parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000079 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000080 #pragma omp target parallel firstprivate (argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000081 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000082 #pragma omp target parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000083 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000084 #pragma omp target parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000085 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000086 #pragma omp target parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000087 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000088 #pragma omp target parallel firstprivate(ba)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000089 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000090 #pragma omp target parallel firstprivate(ca)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000091 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000092 #pragma omp target parallel firstprivate(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000093 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000094 #pragma omp target parallel firstprivate(S2::S2s)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000095 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000096 #pragma omp target parallel firstprivate(S2::S2sc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000097 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000098 #pragma omp target parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000099 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000100 #pragma omp target parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000101 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000102 #pragma omp target parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
103 foo();
104 #pragma omp target parallel shared(i)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000105 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000106 #pragma omp target parallel firstprivate(i)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000107 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000108 #pragma omp target parallel firstprivate(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000109 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000110 #pragma omp target parallel firstprivate(m)
111 foo();
112
113 return 0;
114}