Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / teams_distribute_parallel_for_simd_firstprivate_messages.cpp
blob75027753a0e4c093326083ed735faac5a25ae5e5
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
6 extern int omp_default_mem_alloc;
7 void foo() {
10 bool foobool(int argc) {
11 return argc;
14 void xxx(int argc) {
15 int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
16 #pragma omp target
17 #pragma omp teams distribute parallel for simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
18 for (int i = 0; i < 10; ++i)
22 struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
23 extern S1 a;
24 class S2 {
25 mutable int a;
27 public:
28 S2() : a(0) {}
29 S2(const S2 &s2) : a(s2.a) {}
30 static float S2s;
31 static const float S2sc;
33 const float S2::S2sc = 0;
34 const S2 b;
35 const S2 ba[5];
36 class S3 {
37 int a;
38 S3 &operator=(const S3 &s3);
40 public:
41 S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
42 S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
44 const S3 c;
45 const S3 ca[5];
46 extern const int f;
47 class S4 {
48 int a;
49 S4();
50 S4(const S4 &s4);
51 public:
52 S4(int v):a(v) { }
54 class S5 {
55 int a;
56 S5():a(0) {}
57 S5(const S5 &s5):a(s5.a) { }
58 public:
59 S5(int v):a(v) { }
61 class S6 {
62 int a;
63 public:
64 S6() : a(0) { }
67 S3 h;
68 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
70 int main(int argc, char **argv) {
71 const int d = 5;
72 const int da[5] = { 0 };
73 S4 e(4);
74 S5 g(5);
75 S6 p;
76 int i, z;
77 int &j = i;
79 #pragma omp target
80 #pragma omp teams distribute parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
81 for (i = 0; i < argc; ++i) foo();
83 #pragma omp target
84 #pragma omp teams distribute parallel for simd firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
85 for (i = 0; i < argc; ++i) foo();
87 #pragma omp target
88 #pragma omp teams distribute parallel for simd firstprivate () // expected-error {{expected expression}}
89 for (i = 0; i < argc; ++i) foo();
91 #pragma omp target
92 #pragma omp teams distribute parallel for simd firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for (i = 0; i < argc; ++i) foo();
95 #pragma omp target
96 #pragma omp teams distribute parallel for simd firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
97 for (i = 0; i < argc; ++i) foo();
99 #pragma omp target
100 #pragma omp teams distribute parallel for simd firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
101 for (i = 0; i < argc; ++i) foo();
103 #pragma omp target
104 #pragma omp teams distribute parallel for 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 '('}}
105 for (i = 0; i < argc; ++i) foo();
107 #pragma omp target
108 #pragma omp teams distribute parallel for simd firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
109 for (i = 0; i < argc; ++i) foo();
111 #pragma omp target
112 #pragma omp teams distribute parallel for simd firstprivate (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'}}
113 for (i = 0; i < argc; ++i) foo();
115 #pragma omp target
116 #pragma omp teams distribute parallel for simd firstprivate (argv[1]) // expected-error {{expected variable name}}
117 for (i = 0; i < argc; ++i) foo();
119 #pragma omp target
120 #pragma omp teams distribute parallel for simd firstprivate(ba, z)
121 for (i = 0; i < argc; ++i) foo();
123 #pragma omp target
124 #pragma omp teams distribute parallel for simd firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
125 for (i = 0; i < argc; ++i) foo();
127 #pragma omp target
128 #pragma omp teams distribute parallel for simd firstprivate(da)
129 for (i = 0; i < argc; ++i) foo();
131 #pragma omp target
132 #pragma omp teams distribute parallel for simd firstprivate(S2::S2s)
133 for (i = 0; i < argc; ++i) foo();
135 #pragma omp target
136 #pragma omp teams distribute parallel for simd firstprivate(S2::S2sc)
137 for (i = 0; i < argc; ++i) foo();
139 #pragma omp target
140 #pragma omp teams distribute parallel for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
141 for (i = 0; i < argc; ++i) foo();
143 #pragma omp target
144 #pragma omp teams distribute parallel for simd private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} omp4-note 2 {{defined as private}} omp5-note {{defined as private}}
145 for (i = 0; i < argc; ++i) foo(); // omp4-error {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be private, predetermined as linear}}
147 #pragma omp target
148 #pragma omp teams distribute parallel for simd firstprivate(i)
149 for (j = 0; j < argc; ++j) foo();
151 #pragma omp target
152 #pragma omp teams distribute parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
153 for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
155 #pragma omp target
156 #pragma omp teams distribute parallel for simd firstprivate(j)
157 for (i = 0; i < argc; ++i) foo();
159 // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}}
160 #pragma omp target
161 #pragma omp teams distribute parallel for simd lastprivate(argc), firstprivate(argc)
162 for (i = 0; i < argc; ++i) foo();
164 return 0;