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
;
11 bool foobool(int argc
) {
16 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
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'}}
30 S2(const S2
&s2
) : a(s2
.a
) {}
32 static const float S2sc
;
34 const float S2::S2sc
= 0;
39 S3
&operator=(const S3
&s3
);
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}}
58 S5(const S5
&s5
):a(s5
.a
) { }
69 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
71 int main(int argc
, char **argv
) {
73 const int da
[5] = { 0 };
81 #pragma omp teams distribute simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
82 for (i
= 0; i
< argc
; ++i
) foo();
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();
89 #pragma omp teams distribute simd firstprivate () // expected-error {{expected expression}}
90 for (i
= 0; i
< argc
; ++i
) foo();
93 #pragma omp teams distribute simd firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
94 for (i
= 0; i
< argc
; ++i
) foo();
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();
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();
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();
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();
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();
117 #pragma omp teams distribute simd firstprivate (argv[1]) // expected-error {{expected variable name}}
118 for (i
= 0; i
< argc
; ++i
) foo();
121 #pragma omp teams distribute simd firstprivate(ba)
122 for (i
= 0; i
< argc
; ++i
) foo();
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();
129 #pragma omp teams distribute simd firstprivate(da)
130 for (i
= 0; i
< argc
; ++i
) foo();
133 #pragma omp teams distribute simd firstprivate(S2::S2s)
134 for (i
= 0; i
< argc
; ++i
) foo();
137 #pragma omp teams distribute simd firstprivate(S2::S2sc)
138 for (i
= 0; i
< argc
; ++i
) foo();
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();
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}}
149 #pragma omp teams distribute simd firstprivate(i)
150 for (j
= 0; j
< argc
; ++j
) foo();
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}}
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}}
162 #pragma omp teams distribute simd lastprivate(argc), firstprivate(argc) // OK
163 for (i
= 0; i
< argc
; ++i
) foo();