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