1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++98 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++11 %s -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -std=c++98 %s -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -std=c++11 %s -Wuninitialized
8 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized
9 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++98 %s -Wuninitialized
10 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++11 %s -Wuninitialized
11 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd %s -Wuninitialized
12 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -std=c++98 %s -Wuninitialized
13 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -std=c++11 %s -Wuninitialized
15 // expected-note@* 0+{{declared here}}
20 bool foobool(int argc
) {
26 template <class T
, typename S
, int N
, int ST
>
27 T
tmain(T argc
, S
**argv
) {
28 #pragma omp for collapse // expected-error {{expected '(' after 'collapse'}}
29 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
30 #pragma omp for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
31 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
32 #pragma omp for collapse () // expected-error {{expected expression}}
33 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
34 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
35 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
36 #pragma omp for collapse (argc
37 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
38 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
39 #pragma omp for collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
40 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
41 #pragma omp for collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp for' are ignored}}
42 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
43 #pragma omp for collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
44 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 for', but found only 1}}
45 // expected-error@+3 2 {{directive '#pragma omp for' cannot contain more than one 'collapse' clause}}
46 // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
47 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
48 #pragma omp for collapse (foobool(argc)), collapse (true), collapse (-5)
49 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
50 #pragma omp for collapse (S) // expected-error {{'S' does not refer to a value}}
51 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
52 #if __cplusplus <= 199711L
53 // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
55 // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
57 #pragma omp for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
58 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
59 #pragma omp for collapse (1)
60 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
61 #pragma omp for collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
62 for (T i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
63 #pragma omp for collapse (2) // expected-note {{as specified in 'collapse' clause}}
64 foo(); // expected-error {{expected 2 for loops after '#pragma omp for'}}
68 int main(int argc
, char **argv
) {
69 #pragma omp for collapse // expected-error {{expected '(' after 'collapse'}}
70 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
71 #pragma omp for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
72 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
73 #pragma omp for collapse () // expected-error {{expected expression}}
74 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
75 #pragma omp for collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
76 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 for', but found only 1}}
77 #pragma omp for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp for' are ignored}} expected-note {{as specified in 'collapse' clause}}
78 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 for', but found only 1}}
79 // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
80 #pragma omp for collapse (foobool(1) > 0 ? 1 : 2)
81 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
82 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
83 // expected-error@+2 2 {{directive '#pragma omp for' cannot contain more than one 'collapse' clause}}
84 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
85 #pragma omp for collapse (foobool(argc)), collapse (true), collapse (-5)
86 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
87 #pragma omp for collapse (S1) // expected-error {{'S1' does not refer to a value}}
88 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
89 #if __cplusplus <= 199711L
90 // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
92 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
94 #pragma omp for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
96 // expected-error@+3 {{statement after '#pragma omp for' must be a for loop}}
97 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
98 #pragma omp for collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
100 #pragma omp for collapse (2) // expected-note {{as specified in 'collapse' clause}}
101 foo(); // expected-error {{expected 2 for loops after '#pragma omp for'}}
102 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
103 return tmain
<int, char, 1, 0>(argc
, argv
);
106 void imperfectlyNestedLoops() {
107 #pragma omp for collapse(2) // expected-note {{as specified in 'collapse' clause}}
108 for (int i
= 0; i
< 10; ++i
) { // expected-error {{expected 2 for loops after '#pragma omp for', but found only 1}}
109 for (int j
= 0; j
< 10; ++j
)
111 for (int j
= 0; j
< 10; ++j
)
114 #pragma omp for collapse(2) // expected-note {{as specified in 'collapse' clause}}
115 for (int i
= 0; i
< 10; ++i
) { // expected-error {{expected 2 for loops after '#pragma omp for', but found only 1}}
117 for (int j
= 0; j
< 10; ++j
)
119 for (int j
= 0; j
< 10; ++j
)
123 for (int j
= 0; j
< 10; ++j
)
125 for (int j
= 0; j
< 10; ++j
)
129 #pragma omp for collapse(2) // omp45-note {{as specified in 'collapse' clause}}
130 for (int i
= 0; i
< 10; ++i
) { // omp45-error {{expected 2 for loops after '#pragma omp for', but found only 1}}
132 for (int j
= 0; j
< 10; ++j
)
135 for (int j
= 0; j
< 10; ++j
)
137 for (int j
= 0; j
< 10; ++j
)