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