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