xref: /llvm-project/clang/test/OpenMP/target_parallel_firstprivate_messages.cpp (revision e04483ee35ba28c089cbbcec97a96b67ce0a035e)
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s
4 
5 extern int omp_default_mem_alloc;
6 void foo() {
7 }
8 
9 bool foobool(int argc) {
10   return argc;
11 }
12 
13 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
14 extern S1 a;
15 class S2 {
16   mutable int a;
17 public:
18   S2():a(0) { }
19   S2(const S2 &s2):a(s2.a) { }
20   static float S2s;
21   static const float S2sc;
22 };
23 const float S2::S2sc = 0;
24 const S2 b;
25 const S2 ba[5];
26 class S3 {
27   int a;
28 public:
29   S3():a(0) { }
30   S3(const S3 &s3):a(s3.a) { }
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); // expected-note {{implicitly declared private here}}
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) { } // expected-note {{implicitly declared private here}}
46 public:
47   S5(int v):a(v) { }
48 };
49 
50 S3 h;
51 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
52 
53 namespace A {
54 double x;
55 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
56 }
57 namespace B {
58 using A::x;
59 }
60 
61 int main(int argc, char **argv) {
62   const int d = 5;
63   const int da[5] = { 0 };
64   S4 e(4);
65   S5 g(5);
66   int i;
67   int &j = i;
68   static int m;
69   #pragma omp target parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
70   foo();
71   #pragma omp target parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
72   foo();
73   #pragma omp target parallel firstprivate () // expected-error {{expected expression}}
74   foo();
75   #pragma omp target parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
76   foo();
77   #pragma omp target parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
78   foo();
79   #pragma omp target parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
80   foo();
81   #pragma omp target parallel firstprivate (argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
82   foo();
83   #pragma omp target parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
84   foo();
85   #pragma omp target parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
86   foo();
87   #pragma omp target parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
88   foo();
89   #pragma omp target parallel firstprivate(ba)
90   foo();
91   #pragma omp target parallel firstprivate(ca)
92   foo();
93   #pragma omp target parallel firstprivate(da)
94   foo();
95   #pragma omp target parallel firstprivate(S2::S2s)
96   foo();
97   #pragma omp target parallel firstprivate(S2::S2sc)
98   foo();
99   #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'}}
100   foo();
101   #pragma omp target parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
102   foo();
103   #pragma omp target parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
104   foo();
105   #pragma omp target parallel shared(i)
106   foo();
107   #pragma omp target parallel firstprivate(i)
108   foo();
109   #pragma omp target parallel firstprivate(j)
110   foo();
111   #pragma omp target parallel firstprivate(m)
112   foo();
113 
114   return 0;
115 }
116