xref: /llvm-project/clang/test/OpenMP/masked_taskloop_collapse_messages.cpp (revision 42bb88e2aaee30372065d7704de4d99d4552cfb6)
1*42bb88e2SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2*42bb88e2SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
3*42bb88e2SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
4*42bb88e2SFazlay Rabbi 
5*42bb88e2SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6*42bb88e2SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
7*42bb88e2SFazlay Rabbi // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
8*42bb88e2SFazlay Rabbi 
9*42bb88e2SFazlay Rabbi // expected-note@* 0+{{declared here}}
10*42bb88e2SFazlay Rabbi 
foo()11*42bb88e2SFazlay Rabbi void foo() {
12*42bb88e2SFazlay Rabbi }
13*42bb88e2SFazlay Rabbi 
foobool(int argc)14*42bb88e2SFazlay Rabbi bool foobool(int argc) {
15*42bb88e2SFazlay Rabbi   return argc;
16*42bb88e2SFazlay Rabbi }
17*42bb88e2SFazlay Rabbi 
18*42bb88e2SFazlay Rabbi struct S1;
19*42bb88e2SFazlay Rabbi 
20*42bb88e2SFazlay Rabbi template <class T, typename S, int N, int ST>
tmain(T argc,S ** argv)21*42bb88e2SFazlay Rabbi T tmain(T argc, S **argv) {
22*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse // expected-error {{expected '(' after 'collapse'}}
23*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
24*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
25*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
26*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse () // expected-error {{expected expression}}
27*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28*42bb88e2SFazlay Rabbi   // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
29*42bb88e2SFazlay Rabbi   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
30*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (argc
31*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
32*42bb88e2SFazlay Rabbi   // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
33*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
34*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
35*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp masked taskloop' are ignored}}
36*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
37*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
38*42bb88e2SFazlay Rabbi   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 masked taskloop', but found only 1}}
39*42bb88e2SFazlay Rabbi   // expected-error@+3 2 {{directive '#pragma omp masked taskloop' cannot contain more than one 'collapse' clause}}
40*42bb88e2SFazlay Rabbi   // expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
41*42bb88e2SFazlay Rabbi   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
42*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (foobool(argc)), collapse (true), collapse (-5)
43*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (S) // expected-error {{'S' does not refer to a value}}
45*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
46*42bb88e2SFazlay Rabbi #if __cplusplus <= 199711L
47*42bb88e2SFazlay Rabbi   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
48*42bb88e2SFazlay Rabbi #else
49*42bb88e2SFazlay Rabbi   // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
50*42bb88e2SFazlay Rabbi #endif
51*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
52*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
53*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (1)
54*42bb88e2SFazlay Rabbi   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
55*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
56*42bb88e2SFazlay Rabbi   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
57*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (2) // expected-note {{as specified in 'collapse' clause}}
58*42bb88e2SFazlay Rabbi   foo(); // expected-error {{expected 2 for loops after '#pragma omp masked taskloop'}}
59*42bb88e2SFazlay Rabbi   return argc;
60*42bb88e2SFazlay Rabbi }
61*42bb88e2SFazlay Rabbi 
main(int argc,char ** argv)62*42bb88e2SFazlay Rabbi int main(int argc, char **argv) {
63*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse // expected-error {{expected '(' after 'collapse'}}
64*42bb88e2SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
65*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
66*42bb88e2SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
67*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse () // expected-error {{expected expression}}
68*42bb88e2SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
69*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
70*42bb88e2SFazlay Rabbi   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 masked taskloop', but found only 1}}
71*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp masked taskloop' are ignored}}  expected-note {{as specified in 'collapse' clause}}
72*42bb88e2SFazlay Rabbi   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 masked taskloop', but found only 1}}
73*42bb88e2SFazlay Rabbi   // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
74*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (foobool(1) > 0 ? 1 : 2)
75*42bb88e2SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
76*42bb88e2SFazlay Rabbi   // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
77*42bb88e2SFazlay Rabbi   // expected-error@+2 2 {{directive '#pragma omp masked taskloop' cannot contain more than one 'collapse' clause}}
78*42bb88e2SFazlay Rabbi   // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
79*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (foobool(argc)), collapse (true), collapse (-5)
80*42bb88e2SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
81*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (S1) // expected-error {{'S1' does not refer to a value}}
82*42bb88e2SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
83*42bb88e2SFazlay Rabbi #if __cplusplus <= 199711L
84*42bb88e2SFazlay Rabbi   // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
85*42bb88e2SFazlay Rabbi #else
86*42bb88e2SFazlay Rabbi   // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
87*42bb88e2SFazlay Rabbi #endif
88*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
89*42bb88e2SFazlay Rabbi   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
90*42bb88e2SFazlay Rabbi   // expected-error@+3 {{statement after '#pragma omp masked taskloop' must be a for loop}}
91*42bb88e2SFazlay Rabbi   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
92*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
93*42bb88e2SFazlay Rabbi   foo();
94*42bb88e2SFazlay Rabbi   #pragma omp masked taskloop collapse (2) // expected-note {{as specified in 'collapse' clause}}
95*42bb88e2SFazlay Rabbi   foo(); // expected-error {{expected 2 for loops after '#pragma omp masked taskloop'}}
96*42bb88e2SFazlay Rabbi   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
97*42bb88e2SFazlay Rabbi   return tmain<int, char, 1, 0>(argc, argv);
98*42bb88e2SFazlay Rabbi }
99*42bb88e2SFazlay Rabbi 
100