| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp %s | 
| Paul Robinson | 514e743 | 2016-12-19 17:58:09 +0000 | [diff] [blame^] | 2 | // RUN: %clang_cc1 -verify -fopenmp %s -std=c++98 | 
|  | 3 | // RUN: %clang_cc1 -verify -fopenmp %s -std=c++11 | 
| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 4 |  | 
|  | 5 | void foo() { | 
|  | 6 | } | 
|  | 7 |  | 
| Paul Robinson | 514e743 | 2016-12-19 17:58:09 +0000 | [diff] [blame^] | 8 | #if __cplusplus >= 201103L | 
|  | 9 | // expected-note@+2 4 {{declared here}} | 
|  | 10 | #endif | 
| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 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}} | 
|  | 18 | T tmain(T argc, S **argv) { //expected-note 2 {{declared here}} | 
|  | 19 | #pragma omp target | 
|  | 20 | #pragma omp teams distribute collapse // expected-error {{expected '(' after 'collapse'}} | 
|  | 21 | for (int i = ST; i < N; i++) | 
|  | 22 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 23 |  | 
|  | 24 | #pragma omp target | 
|  | 25 | #pragma omp teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | 
|  | 26 | for (int i = ST; i < N; i++) | 
|  | 27 |  | 
|  | 28 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 29 | #pragma omp target | 
|  | 30 | #pragma omp teams distribute collapse () // expected-error {{expected expression}} | 
|  | 31 | for (int i = ST; i < N; i++) | 
|  | 32 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 33 |  | 
|  | 34 | // expected-error@+4 {{expected ')'}} expected-note@+4 {{to match this '('}} | 
|  | 35 | // expected-error@+3 2 {{expression is not an integral constant expression}} | 
|  | 36 | // expected-note@+2 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} | 
|  | 37 | #pragma omp target | 
|  | 38 | #pragma omp teams distribute collapse (argc | 
|  | 39 | for (int i = ST; i < N; i++) | 
|  | 40 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 41 |  | 
|  | 42 | // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} | 
|  | 43 | #pragma omp target | 
|  | 44 | #pragma omp teams distribute collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}} | 
|  | 45 | for (int i = ST; i < N; i++) | 
|  | 46 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 47 |  | 
|  | 48 | #pragma omp target | 
|  | 49 | #pragma omp teams distribute collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}} | 
|  | 50 | for (int i = ST; i < N; i++) | 
|  | 51 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 52 |  | 
|  | 53 | #pragma omp target | 
|  | 54 | #pragma omp teams distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}} | 
|  | 55 | for (int i = ST; i < N; i++) | 
|  | 56 | argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute', but found only 1}} | 
|  | 57 |  | 
| Paul Robinson | 514e743 | 2016-12-19 17:58:09 +0000 | [diff] [blame^] | 58 | #if __cplusplus >= 201103L | 
|  | 59 | // expected-note@+6 2 {{non-constexpr function 'foobool' cannot be used}} | 
|  | 60 | #endif | 
| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 61 | // expected-error@+4 2 {{directive '#pragma omp teams distribute' cannot contain more than one 'collapse' clause}} | 
|  | 62 | // expected-error@+3 2 {{argument to 'collapse' clause must be a strictly positive integer value}} | 
|  | 63 | // expected-error@+2 2 {{expression is not an integral constant expression}} | 
|  | 64 | #pragma omp target | 
|  | 65 | #pragma omp teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) | 
|  | 66 | for (int i = ST; i < N; i++) | 
|  | 67 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 68 |  | 
|  | 69 | #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}} | 
|  | 70 | for (int i = ST; i < N; i++) | 
|  | 71 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 72 |  | 
| Paul Robinson | 514e743 | 2016-12-19 17:58:09 +0000 | [diff] [blame^] | 73 | #if __cplusplus >= 201103L | 
|  | 74 | // expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}} | 
|  | 75 | #else | 
|  | 76 | // expected-error@+3 2 {{expression is not an integral constant expression}} | 
|  | 77 | #endif | 
| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 78 | #pragma omp target | 
|  | 79 | #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} | 
|  | 80 | for (int i = ST; i < N; i++) | 
|  | 81 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 82 |  | 
|  | 83 | #pragma omp target | 
|  | 84 | #pragma omp teams distribute collapse (1) | 
|  | 85 | for (int i = ST; i < N; i++) | 
|  | 86 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 87 |  | 
|  | 88 | #pragma omp target | 
|  | 89 | #pragma omp teams distribute collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}} | 
|  | 90 | for (T i = ST; i < N; i++) | 
|  | 91 | argv[0][i] = argv[0][i] - argv[0][i-ST]; | 
|  | 92 |  | 
|  | 93 | #pragma omp target | 
|  | 94 | #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}} | 
|  | 95 | foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}} | 
|  | 96 | return argc; | 
|  | 97 | } | 
|  | 98 |  | 
|  | 99 | int main(int argc, char **argv) { | 
|  | 100 | #pragma omp target | 
|  | 101 | #pragma omp teams distribute collapse // expected-error {{expected '(' after 'collapse'}} | 
|  | 102 | for (int i = 4; i < 12; i++) | 
|  | 103 | argv[0][i] = argv[0][i] - argv[0][i-4]; | 
|  | 104 |  | 
|  | 105 | #pragma omp target | 
|  | 106 | #pragma omp teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} | 
|  | 107 | for (int i = 4; i < 12; i++) | 
|  | 108 | argv[0][i] = argv[0][i] - argv[0][i-4]; | 
|  | 109 |  | 
|  | 110 | #pragma omp target | 
|  | 111 | #pragma omp teams distribute collapse () // expected-error {{expected expression}} | 
|  | 112 | for (int i = 4; i < 12; i++) | 
|  | 113 | argv[0][i] = argv[0][i] - argv[0][i-4]; | 
|  | 114 |  | 
|  | 115 | #pragma omp target | 
|  | 116 | #pragma omp teams distribute collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}} | 
|  | 117 | for (int i = 4; i < 12; i++) | 
|  | 118 | argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}} | 
|  | 119 |  | 
|  | 120 | #pragma omp target | 
|  | 121 | #pragma omp teams distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute' are ignored}}  expected-note {{as specified in 'collapse' clause}} | 
|  | 122 | for (int i = 4; i < 12; i++) | 
|  | 123 | argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute', but found only 1}} | 
|  | 124 |  | 
| Paul Robinson | 514e743 | 2016-12-19 17:58:09 +0000 | [diff] [blame^] | 125 | #if __cplusplus >= 201103L | 
|  | 126 | // expected-note@+3 {{non-constexpr function 'foobool' cannot be used}} | 
|  | 127 | #endif | 
| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 128 | #pragma omp target | 
|  | 129 | #pragma omp teams distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} | 
|  | 130 | for (int i = 4; i < 12; i++) | 
|  | 131 | argv[0][i] = argv[0][i] - argv[0][i-4]; | 
|  | 132 |  | 
| Paul Robinson | 514e743 | 2016-12-19 17:58:09 +0000 | [diff] [blame^] | 133 | #if __cplusplus >= 201103L | 
|  | 134 | // expected-note@+6 {{non-constexpr function 'foobool' cannot be used}} | 
|  | 135 | #endif | 
| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 136 | // expected-error@+4 {{expression is not an integral constant expression}} | 
|  | 137 | // expected-error@+3 2 {{directive '#pragma omp teams distribute' cannot contain more than one 'collapse' clause}} | 
|  | 138 | // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} | 
|  | 139 | #pragma omp target | 
|  | 140 | #pragma omp teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) | 
|  | 141 | for (int i = 4; i < 12; i++) | 
|  | 142 | argv[0][i] = argv[0][i] - argv[0][i-4]; | 
|  | 143 |  | 
|  | 144 | #pragma omp target | 
|  | 145 | #pragma omp teams distribute collapse (S1) // expected-error {{'S1' does not refer to a value}} | 
|  | 146 | for (int i = 4; i < 12; i++) | 
|  | 147 | argv[0][i] = argv[0][i] - argv[0][i-4]; | 
|  | 148 |  | 
| Paul Robinson | 514e743 | 2016-12-19 17:58:09 +0000 | [diff] [blame^] | 149 | #if __cplusplus >= 201103L | 
|  | 150 | // expected-error@+5 {{integral constant expression must have integral or unscoped enumeration type}} | 
|  | 151 | #else | 
|  | 152 | // expected-error@+3 {{expression is not an integral constant expression}} | 
|  | 153 | #endif | 
| Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 154 | #pragma omp target | 
|  | 155 | #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} | 
|  | 156 | for (int i = 4; i < 12; i++) | 
|  | 157 | argv[0][i] = argv[0][i] - argv[0][i-4]; | 
|  | 158 |  | 
|  | 159 | // expected-error@+4 {{statement after '#pragma omp teams distribute' must be a for loop}} | 
|  | 160 | // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}} | 
|  | 161 | #pragma omp target | 
|  | 162 | #pragma omp teams distribute collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} | 
|  | 163 | foo(); | 
|  | 164 |  | 
|  | 165 | #pragma omp target | 
|  | 166 | #pragma omp teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}} | 
|  | 167 | foo(); // expected-error {{expected 2 for loops after '#pragma omp teams distribute'}} | 
|  | 168 |  | 
|  | 169 | // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}} | 
|  | 170 | return tmain<int, char, 1, 0>(argc, argv); | 
|  | 171 | } | 
|  | 172 |  |