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