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