1a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
3a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
44a39add0SKelvin Li
5a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
7a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
8a8a9153aSAlexey Bataev
9*ebf6fd63SRichard Smith // expected-note@* 0+{{declared here}}
10*ebf6fd63SRichard Smith
foo()114a39add0SKelvin Li void foo() {
124a39add0SKelvin Li }
134a39add0SKelvin Li
foobool(int argc)144a39add0SKelvin Li bool foobool(int argc) {
154a39add0SKelvin Li return argc;
164a39add0SKelvin Li }
174a39add0SKelvin Li
18*ebf6fd63SRichard Smith struct S1;
194a39add0SKelvin Li
20*ebf6fd63SRichard Smith template <class T, typename S, int N, int ST>
tmain(T argc,S ** argv)21*ebf6fd63SRichard Smith T tmain(T argc, S **argv) {
224a39add0SKelvin Li #pragma omp target
234a39add0SKelvin Li #pragma omp teams
244a39add0SKelvin Li #pragma omp distribute parallel for simd collapse // expected-error {{expected '(' after 'collapse'}}
254a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
264a39add0SKelvin Li #pragma omp target
274a39add0SKelvin Li #pragma omp teams
284a39add0SKelvin Li #pragma omp distribute parallel for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
294a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
304a39add0SKelvin Li #pragma omp target
314a39add0SKelvin Li #pragma omp teams
324a39add0SKelvin Li #pragma omp distribute parallel for simd collapse () // expected-error {{expected expression}}
334a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
344a39add0SKelvin Li #pragma omp target
354a39add0SKelvin Li #pragma omp teams
36*ebf6fd63SRichard Smith // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
37*ebf6fd63SRichard Smith // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
384a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (argc
394a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
404a39add0SKelvin Li #pragma omp target
414a39add0SKelvin Li #pragma omp teams
424a39add0SKelvin Li // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
434a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
444a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
454a39add0SKelvin Li #pragma omp target
464a39add0SKelvin Li #pragma omp teams
474a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
484a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
494a39add0SKelvin Li #pragma omp target
504a39add0SKelvin Li #pragma omp teams
514a39add0SKelvin Li #pragma omp distribute parallel for simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
524a39add0SKelvin Li 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 parallel for simd', but found only 1}}
53*ebf6fd63SRichard Smith // expected-error@+5 2 {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'collapse' clause}}
54*ebf6fd63SRichard Smith // expected-error@+4 {{argument to 'collapse' clause must be a strictly positive integer value}}
55*ebf6fd63SRichard Smith // expected-error@+3 2 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
564a39add0SKelvin Li #pragma omp target
574a39add0SKelvin Li #pragma omp teams
584a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (foobool(argc)), collapse (true), collapse (-5)
594a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
604a39add0SKelvin Li #pragma omp target
614a39add0SKelvin Li #pragma omp teams
624a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (S) // expected-error {{'S' does not refer to a value}}
634a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
644a39add0SKelvin Li #if __cplusplus <= 199711L
65*ebf6fd63SRichard Smith // expected-error@+6 2 {{integral constant expression}} expected-note@+6 0+{{constant expression}}
664a39add0SKelvin Li #else
674a39add0SKelvin Li // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
684a39add0SKelvin Li #endif
694a39add0SKelvin Li #pragma omp target
704a39add0SKelvin Li #pragma omp teams
714a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
724a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
734a39add0SKelvin Li #pragma omp target
744a39add0SKelvin Li #pragma omp teams
754a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (1)
764a39add0SKelvin Li for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
774a39add0SKelvin Li #pragma omp target
784a39add0SKelvin Li #pragma omp teams
794a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
804a39add0SKelvin Li for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
814a39add0SKelvin Li #pragma omp target
824a39add0SKelvin Li #pragma omp teams
834a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
844a39add0SKelvin Li foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute parallel for simd'}}
854a39add0SKelvin Li return argc;
864a39add0SKelvin Li }
874a39add0SKelvin Li
main(int argc,char ** argv)884a39add0SKelvin Li int main(int argc, char **argv) {
894a39add0SKelvin Li #pragma omp target
904a39add0SKelvin Li #pragma omp teams
914a39add0SKelvin Li #pragma omp distribute parallel for simd collapse // expected-error {{expected '(' after 'collapse'}}
924a39add0SKelvin Li for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
934a39add0SKelvin Li #pragma omp target
944a39add0SKelvin Li #pragma omp teams
954a39add0SKelvin Li #pragma omp distribute parallel for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
964a39add0SKelvin Li for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
974a39add0SKelvin Li #pragma omp target
984a39add0SKelvin Li #pragma omp teams
994a39add0SKelvin Li #pragma omp distribute parallel for simd collapse () // expected-error {{expected expression}}
1004a39add0SKelvin Li for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
1014a39add0SKelvin Li #pragma omp target
1024a39add0SKelvin Li #pragma omp teams
1034a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
1044a39add0SKelvin Li 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 parallel for simd', but found only 1}}
1054a39add0SKelvin Li #pragma omp target
1064a39add0SKelvin Li #pragma omp teams
1074a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
1084a39add0SKelvin Li 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 parallel for simd', but found only 1}}
109*ebf6fd63SRichard Smith // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
1104a39add0SKelvin Li #pragma omp target
1114a39add0SKelvin Li #pragma omp teams
1124a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (foobool(1) > 0 ? 1 : 2)
1134a39add0SKelvin Li for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
114*ebf6fd63SRichard Smith // expected-error@+5 {{integral constant expression}} expected-note@+5 0+{{constant expression}}
1154a39add0SKelvin Li // expected-error@+4 2 {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'collapse' clause}}
1163234887fSJoel E. Denny // expected-error@+3 {{argument to 'collapse' clause must be a strictly positive integer value}}
1174a39add0SKelvin Li #pragma omp target
1184a39add0SKelvin Li #pragma omp teams
1194a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (foobool(argc)), collapse (true), collapse (-5)
1204a39add0SKelvin Li for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
1214a39add0SKelvin Li #pragma omp target
1224a39add0SKelvin Li #pragma omp teams
1234a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
1244a39add0SKelvin Li for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
1254a39add0SKelvin Li #if __cplusplus <= 199711L
126*ebf6fd63SRichard Smith // expected-error@+6 {{integral constant expression}} expected-note@+6 0+{{constant expression}}
1274a39add0SKelvin Li #else
1284a39add0SKelvin Li // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
1294a39add0SKelvin Li #endif
1304a39add0SKelvin Li #pragma omp target
1314a39add0SKelvin Li #pragma omp teams
1324a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
1334a39add0SKelvin Li for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
1344a39add0SKelvin Li // expected-error@+5 {{statement after '#pragma omp distribute parallel for simd' must be a for loop}}
1354a39add0SKelvin Li // expected-note@+3 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
1364a39add0SKelvin Li #pragma omp target
1374a39add0SKelvin Li #pragma omp teams
1384a39add0SKelvin Li #pragma omp distribute parallel for simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
1394a39add0SKelvin Li foo();
1404a39add0SKelvin Li #pragma omp target
1414a39add0SKelvin Li #pragma omp teams
1424a39add0SKelvin Li #pragma omp distribute parallel for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
1434a39add0SKelvin Li foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute parallel for simd'}}
1444a39add0SKelvin Li // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
1454a39add0SKelvin Li return tmain<int, char, 1, 0>(argc, argv);
1464a39add0SKelvin Li }
1474a39add0SKelvin Li
148