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 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 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 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 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 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 collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' 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 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', but found only 1}}
60 // expected-error@+4 2 {{directive '#pragma omp teams distribute' 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 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
];
69 #pragma omp teams distribute collapse (S) // expected-error {{'S' does not refer to a value}}
70 for (int i
= ST
; i
< N
; i
++)
71 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
73 #if __cplusplus >= 201103L
74 // expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}}
76 // expected-error@+3 2 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
79 #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
80 for (int i
= ST
; i
< N
; i
++)
81 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
84 #pragma omp teams distribute collapse (1)
85 for (int i
= ST
; i
< N
; i
++)
86 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
89 #pragma omp teams distribute collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
90 for (T i
= ST
; i
< N
; i
++)
91 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
94 #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
95 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}}
99 int main(int argc
, char **argv
) {
101 #pragma omp teams distribute collapse // expected-error {{expected '(' after 'collapse'}}
102 for (int i
= 4; i
< 12; i
++)
103 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
106 #pragma omp teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
107 for (int i
= 4; i
< 12; i
++)
108 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
111 #pragma omp teams distribute collapse () // expected-error {{expected expression}}
112 for (int i
= 4; i
< 12; i
++)
113 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
116 #pragma omp teams distribute collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
117 for (int i
= 4; i
< 12; i
++)
118 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}}
121 #pragma omp teams distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}} expected-note {{as specified in 'collapse' clause}}
122 for (int i
= 4; i
< 12; i
++)
123 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}}
126 #pragma omp teams distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
127 for (int i
= 4; i
< 12; i
++)
128 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
130 // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
131 // expected-error@+3 2 {{directive '#pragma omp teams distribute' cannot contain more than one 'collapse' clause}}
132 // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
134 #pragma omp teams distribute collapse (foobool(argc)), collapse (true), collapse (-5)
135 for (int i
= 4; i
< 12; i
++)
136 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
139 #pragma omp teams distribute collapse (S1) // expected-error {{'S1' does not refer to a value}}
140 for (int i
= 4; i
< 12; i
++)
141 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
143 #if __cplusplus >= 201103L
144 // expected-error@+5 {{integral constant expression must have integral or unscoped enumeration type}}
146 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
149 #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
150 for (int i
= 4; i
< 12; i
++)
151 argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
153 // expected-error@+4 {{statement after '#pragma omp teams distribute' must be a for loop}}
154 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
156 #pragma omp teams distribute collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
160 #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
161 foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}}
163 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
164 return tmain
<int, char, 1, 0>(argc
, argv
);