1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++98 -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp %s -std=c++11 -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++98 -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd %s -std=c++11 -Wuninitialized
9 // expected-note@* 0+{{declared here}}
14 bool foobool(int argc
) {
20 template <class T
, typename S
, int N
, int ST
>
21 T
tmain(T argc
, S
**argv
) {
23 #pragma omp teams distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
24 for (int i
= ST
; i
< N
; i
++)
25 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
28 #pragma omp teams distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
29 for (int i
= ST
; i
< N
; i
++)
31 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
33 #pragma omp teams distribute parallel for collapse () // expected-error {{expected expression}}
34 for (int i
= ST
; i
< N
; i
++)
35 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
37 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
38 // expected-error@+2 2 {{integral constant expression}} expected-note@+2 0+{{constant expression}}
40 #pragma omp teams distribute parallel for collapse (argc
41 for (int i
= ST
; i
< N
; i
++)
42 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
44 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
46 #pragma omp teams distribute parallel for collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
47 for (int i
= ST
; i
< N
; i
++)
48 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
51 #pragma omp teams distribute parallel for collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
52 for (int i
= ST
; i
< N
; i
++)
53 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
56 #pragma omp teams distribute parallel for collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
57 for (int i
= ST
; i
< N
; i
++)
58 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute parallel for', but found only 1}}
60 // expected-error@+4 2 {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'collapse' clause}}
61 // expected-error@+3 {{argument to 'collapse' clause must be a strictly positive integer value}}
62 // expected-error@+2 2 {{integral constant expression}} expected-note@+2 0+{{constant expression}}
64 #pragma omp teams distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
65 for (int i
= ST
; i
< N
; i
++)
66 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
68 #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}}
69 for (int i
= ST
; i
< N
; i
++)
70 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
72 #if __cplusplus >= 201103L
73 // expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}}
75 // expected-error@+3 2 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
78 #pragma omp teams distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
79 for (int i
= ST
; i
< N
; i
++)
80 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
83 #pragma omp teams distribute parallel for collapse (1)
84 for (int i
= ST
; i
< N
; i
++)
85 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
88 #pragma omp teams distribute parallel for collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
89 for (T i
= ST
; i
< N
; i
++)
90 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
93 #pragma omp teams distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
94 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute parallel for'}}
98 int main(int argc
, char **argv
) {
100 #pragma omp teams distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
101 for (int i
= 4; i
< 12; i
++)
102 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
105 #pragma omp teams distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
106 for (int i
= 4; i
< 12; i
++)
107 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
110 #pragma omp teams distribute parallel for collapse () // expected-error {{expected expression}}
111 for (int i
= 4; i
< 12; i
++)
112 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
115 #pragma omp teams distribute parallel for collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
116 for (int i
= 4; i
< 12; i
++)
117 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for', but found only 1}}
120 #pragma omp teams distribute parallel for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} expected-note {{as specified in 'collapse' clause}}
121 for (int i
= 4; i
< 12; i
++)
122 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for', but found only 1}}
125 #pragma omp teams distribute parallel for collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
126 for (int i
= 4; i
< 12; i
++)
127 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
129 // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
130 // expected-error@+3 2 {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'collapse' clause}}
131 // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
133 #pragma omp teams distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
134 for (int i
= 4; i
< 12; i
++)
135 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
138 #pragma omp teams distribute parallel for collapse (S1) // expected-error {{'S1' does not refer to a value}}
139 for (int i
= 4; i
< 12; i
++)
140 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
142 #if __cplusplus >= 201103L
143 // expected-error@+5 {{integral constant expression must have integral or unscoped enumeration type}}
145 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
148 #pragma omp teams distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
149 for (int i
= 4; i
< 12; i
++)
150 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
152 // expected-error@+4 {{statement after '#pragma omp teams distribute parallel for' must be a for loop}}
153 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
155 #pragma omp teams distribute parallel for collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
159 #pragma omp teams distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
160 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute parallel for'}}
162 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
163 return tmain
<int, char, 1, 0>(argc
, argv
);