[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / teams_distribute_simd_firstprivate_messages.cpp
blob721aafc23f5d76e0b31242b0f444b75bad1f6e82
1 // RUN: %clang_cc1 -verify=expected,omp4 -fopenmp -fopenmp-version=45 %s -Wno-openmp-mapping -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp5 -fopenmp %s -Wno-openmp-mapping -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,omp4 -fopenmp-simd -fopenmp-version=45 %s -Wno-openmp-mapping -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp5 -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized
7 extern int omp_default_mem_alloc;
8 void foo() {
11 bool foobool(int argc) {
12 return argc;
15 void xxx(int argc) {
16 int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
17 #pragma omp target
18 #pragma omp teams distribute simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
19 for (int i = 0; i < 10; ++i)
23 struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
24 extern S1 a;
25 class S2 {
26 mutable int a;
28 public:
29 S2() : a(0) {}
30 S2(const S2 &s2) : a(s2.a) {}
31 static float S2s;
32 static const float S2sc;
34 const float S2::S2sc = 0;
35 const S2 b;
36 const S2 ba[5];
37 class S3 {
38 int a;
39 S3 &operator=(const S3 &s3);
41 public:
42 S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
43 S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
45 const S3 c;
46 const S3 ca[5];
47 extern const int f;
48 class S4 {
49 int a;
50 S4();
51 S4(const S4 &s4);
52 public:
53 S4(int v):a(v) { }
55 class S5 {
56 int a;
57 S5():a(0) {}
58 S5(const S5 &s5):a(s5.a) { }
59 public:
60 S5(int v):a(v) { }
62 class S6 {
63 int a;
64 public:
65 S6() : a(0) { }
68 S3 h;
69 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
71 int main(int argc, char **argv) {
72 const int d = 5;
73 const int da[5] = { 0 };
74 S4 e(4);
75 S5 g(5);
76 S6 p;
77 int i, k;
78 int &j = i;
80 #pragma omp target
81 #pragma omp teams distribute simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
82 for (i = 0; i < argc; ++i) foo();
84 #pragma omp target
85 #pragma omp teams distribute simd firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
86 for (i = 0; i < argc; ++i) foo();
88 #pragma omp target
89 #pragma omp teams distribute simd firstprivate () // expected-error {{expected expression}}
90 for (i = 0; i < argc; ++i) foo();
92 #pragma omp target
93 #pragma omp teams distribute simd firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
94 for (i = 0; i < argc; ++i) foo();
96 #pragma omp target
97 #pragma omp teams distribute simd firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
98 for (i = 0; i < argc; ++i) foo();
100 #pragma omp target
101 #pragma omp teams distribute simd firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
102 for (i = 0; i < argc; ++i) foo();
104 #pragma omp target
105 #pragma omp teams distribute simd 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 '('}}
106 for (i = 0; i < argc; ++i) foo();
108 #pragma omp target
109 #pragma omp teams distribute simd firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
110 for (i = 0; i < argc; ++i) foo();
112 #pragma omp target
113 #pragma omp teams distribute simd firstprivate (k, a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{incomplete type 'S1' where a complete type is required}} expected-error {{no matching constructor for initialization of 'S3'}}
114 for (i = 0; i < argc; ++i) foo();
116 #pragma omp target
117 #pragma omp teams distribute simd firstprivate (argv[1]) // expected-error {{expected variable name}}
118 for (i = 0; i < argc; ++i) foo();
120 #pragma omp target
121 #pragma omp teams distribute simd firstprivate(ba)
122 for (i = 0; i < argc; ++i) foo();
124 #pragma omp target
125 #pragma omp teams distribute simd firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
126 for (i = 0; i < argc; ++i) foo();
128 #pragma omp target
129 #pragma omp teams distribute simd firstprivate(da)
130 for (i = 0; i < argc; ++i) foo();
132 #pragma omp target
133 #pragma omp teams distribute simd firstprivate(S2::S2s)
134 for (i = 0; i < argc; ++i) foo();
136 #pragma omp target
137 #pragma omp teams distribute simd firstprivate(S2::S2sc)
138 for (i = 0; i < argc; ++i) foo();
140 #pragma omp target
141 #pragma omp teams distribute simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
142 for (i = 0; i < argc; ++i) foo();
144 #pragma omp target
145 #pragma omp teams distribute simd private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} omp4-note 2 {{defined as private}} omp5-note {{defined as private}}
146 for (i = 0; i < argc; ++i) foo(); // omp4-error {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be private, predetermined as linear}}
148 #pragma omp target
149 #pragma omp teams distribute simd firstprivate(i)
150 for (j = 0; j < argc; ++j) foo();
152 #pragma omp target
153 #pragma omp teams distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}
154 for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be firstprivate, predetermined as linear}}
156 #pragma omp target
157 #pragma omp teams distribute simd firstprivate(j)
158 for (i = 0; i < argc; ++i) foo();
160 // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}}
161 #pragma omp target
162 #pragma omp teams distribute simd lastprivate(argc), firstprivate(argc) // OK
163 for (i = 0; i < argc; ++i) foo();
165 return 0;