1*38bcd483SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2*38bcd483SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
3*38bcd483SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
4*38bcd483SFazlay Rabbi 
5*38bcd483SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6*38bcd483SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
7*38bcd483SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
8*38bcd483SFazlay Rabbi 
9*38bcd483SFazlay Rabbi // expected-note@* 0+{{declared here}}
10*38bcd483SFazlay Rabbi 
foo()11*38bcd483SFazlay Rabbi void foo() {
12*38bcd483SFazlay Rabbi }
13*38bcd483SFazlay Rabbi 
foobool(int argc)14*38bcd483SFazlay Rabbi bool foobool(int argc) {
15*38bcd483SFazlay Rabbi   return argc;
16*38bcd483SFazlay Rabbi }
17*38bcd483SFazlay Rabbi 
18*38bcd483SFazlay Rabbi struct S1;
19*38bcd483SFazlay Rabbi 
20*38bcd483SFazlay Rabbi template <class T, typename S, int N, int ST>
tmain(T argc,S ** argv)21*38bcd483SFazlay Rabbi T tmain(T argc, S **argv) {
22*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse // expected-error {{expected '(' after 'collapse'}}
23*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
24*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
25*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
26*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse () // expected-error {{expected expression}}
27*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28*38bcd483SFazlay Rabbi   // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
29*38bcd483SFazlay Rabbi   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
30*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (argc
31*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
32*38bcd483SFazlay Rabbi   // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
33*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
34*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
35*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp parallel masked taskloop simd' are ignored}}
36*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
37*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
38*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp parallel masked taskloop simd', but found only 1}}
39*38bcd483SFazlay Rabbi   // expected-error@+3 2 {{directive '#pragma omp parallel masked taskloop simd' cannot contain more than one 'collapse' clause}}
40*38bcd483SFazlay Rabbi   // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
41*38bcd483SFazlay Rabbi   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
42*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (foobool(argc)), collapse (true), collapse (-5)
43*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (S) // expected-error {{'S' does not refer to a value}}
45*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
46*38bcd483SFazlay Rabbi #if __cplusplus <= 199711L
47*38bcd483SFazlay Rabbi   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
48*38bcd483SFazlay Rabbi #else
49*38bcd483SFazlay Rabbi   // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
50*38bcd483SFazlay Rabbi #endif
51*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
52*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
53*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (1)
54*38bcd483SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
55*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
56*38bcd483SFazlay Rabbi   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
57*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
58*38bcd483SFazlay Rabbi   foo(); // expected-error {{expected 2 for loops after '#pragma omp parallel masked taskloop simd'}}
59*38bcd483SFazlay Rabbi   return argc;
60*38bcd483SFazlay Rabbi }
61*38bcd483SFazlay Rabbi 
main(int argc,char ** argv)62*38bcd483SFazlay Rabbi int main(int argc, char **argv) {
63*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse // expected-error {{expected '(' after 'collapse'}}
64*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
65*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
66*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
67*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse () // expected-error {{expected expression}}
68*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
69*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
70*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp parallel masked taskloop simd', but found only 1}}
71*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel masked taskloop simd' are ignored}}  expected-note {{as specified in 'collapse' clause}}
72*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp parallel masked taskloop simd', but found only 1}}
73*38bcd483SFazlay Rabbi   // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
74*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (foobool(1) > 0 ? 1 : 2)
75*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
76*38bcd483SFazlay Rabbi   // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
77*38bcd483SFazlay Rabbi   // expected-error@+2 2 {{directive '#pragma omp parallel masked taskloop simd' cannot contain more than one 'collapse' clause}}
78*38bcd483SFazlay Rabbi   // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
79*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (foobool(argc)), collapse (true), collapse (-5)
80*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
81*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
82*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
83*38bcd483SFazlay Rabbi #if __cplusplus <= 199711L
84*38bcd483SFazlay Rabbi   // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
85*38bcd483SFazlay Rabbi #else
86*38bcd483SFazlay Rabbi   // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
87*38bcd483SFazlay Rabbi #endif
88*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
89*38bcd483SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
90*38bcd483SFazlay Rabbi   // expected-error@+3 {{statement after '#pragma omp parallel masked taskloop simd' must be a for loop}}
91*38bcd483SFazlay Rabbi   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
92*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
93*38bcd483SFazlay Rabbi   foo();
94*38bcd483SFazlay Rabbi   #pragma omp parallel masked taskloop simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
95*38bcd483SFazlay Rabbi   foo(); // expected-error {{expected 2 for loops after '#pragma omp parallel masked taskloop simd'}}
96*38bcd483SFazlay Rabbi   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
97*38bcd483SFazlay Rabbi   return tmain<int, char, 1, 0>(argc, argv);
98*38bcd483SFazlay Rabbi }
99*38bcd483SFazlay Rabbi 
100