xref: /llvm-project/clang/test/OpenMP/parallel_master_taskloop_simd_collapse_messages.cpp (revision ebf6fd633ef83b747bac721aafc3677d2c47aef1)
114a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
214a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
314a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
414a388f4SAlexey Bataev 
514a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
614a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
714a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
814a388f4SAlexey Bataev 
9*ebf6fd63SRichard Smith // expected-note@* 0+{{declared here}}
10*ebf6fd63SRichard Smith 
foo()1114a388f4SAlexey Bataev void foo() {
1214a388f4SAlexey Bataev }
1314a388f4SAlexey Bataev 
foobool(int argc)1414a388f4SAlexey Bataev bool foobool(int argc) {
1514a388f4SAlexey Bataev   return argc;
1614a388f4SAlexey Bataev }
1714a388f4SAlexey Bataev 
18*ebf6fd63SRichard Smith struct S1;
1914a388f4SAlexey Bataev 
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) {
2214a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse // expected-error {{expected '(' after 'collapse'}}
2314a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
2414a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
2514a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
2614a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse () // expected-error {{expected expression}}
2714a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28*ebf6fd63SRichard Smith   // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
29*ebf6fd63SRichard Smith   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
3014a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (argc
3114a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3214a388f4SAlexey Bataev   // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
3314a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
3414a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3514a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
3614a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3714a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
3814a388f4SAlexey Bataev   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 parallel master taskloop simd', but found only 1}}
39*ebf6fd63SRichard Smith   // expected-error@+3 2 {{directive '#pragma omp parallel master taskloop simd' cannot contain more than one 'collapse' clause}}
40*ebf6fd63SRichard Smith   // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
41*ebf6fd63SRichard Smith   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
4214a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (foobool(argc)), collapse (true), collapse (-5)
4314a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
4414a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (S) // expected-error {{'S' does not refer to a value}}
4514a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
4614a388f4SAlexey Bataev #if __cplusplus <= 199711L
47*ebf6fd63SRichard Smith   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
4814a388f4SAlexey Bataev #else
4914a388f4SAlexey Bataev   // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
5014a388f4SAlexey Bataev #endif
5114a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
5214a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
5314a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (1)
5414a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
5514a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
5614a388f4SAlexey Bataev   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
5714a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
5814a388f4SAlexey Bataev   foo(); // expected-error {{expected 2 for loops after '#pragma omp parallel master taskloop simd'}}
5914a388f4SAlexey Bataev   return argc;
6014a388f4SAlexey Bataev }
6114a388f4SAlexey Bataev 
main(int argc,char ** argv)6214a388f4SAlexey Bataev int main(int argc, char **argv) {
6314a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse // expected-error {{expected '(' after 'collapse'}}
6414a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
6514a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
6614a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
6714a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse () // expected-error {{expected expression}}
6814a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
6914a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
7014a388f4SAlexey Bataev   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 parallel master taskloop simd', but found only 1}}
7114a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}  expected-note {{as specified in 'collapse' clause}}
7214a388f4SAlexey Bataev   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 parallel master taskloop simd', but found only 1}}
73*ebf6fd63SRichard Smith   // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
7414a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (foobool(1) > 0 ? 1 : 2)
7514a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
76*ebf6fd63SRichard Smith   // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
7714a388f4SAlexey Bataev   // expected-error@+2 2 {{directive '#pragma omp parallel master taskloop simd' cannot contain more than one 'collapse' clause}}
7814a388f4SAlexey Bataev   // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
7914a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (foobool(argc)), collapse (true), collapse (-5)
8014a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
8114a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
8214a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
8314a388f4SAlexey Bataev #if __cplusplus <= 199711L
84*ebf6fd63SRichard Smith   // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
8514a388f4SAlexey Bataev #else
8614a388f4SAlexey Bataev   // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
8714a388f4SAlexey Bataev #endif
8814a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
8914a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
9014a388f4SAlexey Bataev   // expected-error@+3 {{statement after '#pragma omp parallel master taskloop simd' must be a for loop}}
9114a388f4SAlexey Bataev   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
9214a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
9314a388f4SAlexey Bataev   foo();
9414a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
9514a388f4SAlexey Bataev   foo(); // expected-error {{expected 2 for loops after '#pragma omp parallel master taskloop simd'}}
9614a388f4SAlexey Bataev   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
9714a388f4SAlexey Bataev   return tmain<int, char, 1, 0>(argc, argv);
9814a388f4SAlexey Bataev }
9914a388f4SAlexey Bataev 
100