1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -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
) {
24 #pragma omp distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
25 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
28 #pragma omp distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
29 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
32 #pragma omp distribute simd collapse () // expected-error {{expected expression}}
33 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
36 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
37 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
38 #pragma omp distribute simd collapse (argc
39 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
42 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
43 #pragma omp distribute simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
44 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
47 #pragma omp distribute simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
48 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
51 #pragma omp distribute simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
52 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 distribute simd', but found only 1}}
53 // expected-error@+5 2 {{directive '#pragma omp distribute simd' cannot contain more than one 'collapse' clause}}
54 // expected-error@+4 {{argument to 'collapse' clause must be a strictly positive integer value}}
55 // expected-error@+3 2 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
58 #pragma omp distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
59 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
62 #pragma omp distribute simd collapse (S) // expected-error {{'S' does not refer to a value}}
63 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
64 #if __cplusplus <= 199711L
65 // expected-error@+6 2 {{integral constant expression}} expected-note@+6 0+{{constant expression}}
67 // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
71 #pragma omp distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
72 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
75 #pragma omp distribute simd collapse (1)
76 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
79 #pragma omp distribute simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
80 for (T i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
83 #pragma omp distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
84 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute simd'}}
88 int main(int argc
, char **argv
) {
91 #pragma omp distribute simd collapse // expected-error {{expected '(' after 'collapse'}}
92 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
95 #pragma omp distribute simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
96 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
99 #pragma omp distribute simd collapse () // expected-error {{expected expression}}
100 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
103 #pragma omp distribute simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
104 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 distribute simd', but found only 1}}
107 #pragma omp distribute simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
108 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 distribute simd', but found only 1}}
109 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
112 #pragma omp distribute simd collapse (foobool(1) > 0 ? 1 : 2)
113 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
114 // expected-error@+5 {{integral constant expression}} expected-note@+5 0+{{constant expression}}
115 // expected-error@+4 2 {{directive '#pragma omp distribute simd' cannot contain more than one 'collapse' clause}}
116 // expected-error@+3 {{argument to 'collapse' clause must be a strictly positive integer value}}
119 #pragma omp distribute simd collapse (foobool(argc)), collapse (true), collapse (-5)
120 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
123 #pragma omp distribute simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
124 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
125 #if __cplusplus <= 199711L
126 // expected-error@+6 {{integral constant expression}} expected-note@+6 0+{{constant expression}}
128 // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
132 #pragma omp distribute simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
133 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
134 // expected-error@+5 {{statement after '#pragma omp distribute simd' must be a for loop}}
135 // expected-note@+3 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
138 #pragma omp distribute simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
142 #pragma omp distribute simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
143 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute simd'}}
144 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
145 return tmain
<int, char, 1, 0>(argc
, argv
);