| 1 |
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 -fopenmp -fopenmp-version=60 -fsyntax-only -Wuninitialized -verify %s |
| 2 |
|
| 3 |
void func() { |
| 4 |
|
| 5 |
// expected-error@+1 {{expected '('}} |
| 6 |
#pragma omp interchange permutation |
| 7 |
for (int i = 0; i < 7; ++i) |
| 8 |
for (int j = 0; j < 13; ++j) |
| 9 |
; |
| 10 |
|
| 11 |
// expected-error@+2 {{expected expression}} |
| 12 |
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 13 |
#pragma omp interchange permutation( |
| 14 |
for (int i = 0; i < 7; ++i) |
| 15 |
for (int j = 0; j < 13; ++j) |
| 16 |
; |
| 17 |
|
| 18 |
// expected-error@+1 {{expected expression}} |
| 19 |
#pragma omp interchange permutation() |
| 20 |
for (int i = 0; i < 7; ++i) |
| 21 |
for (int j = 0; j < 13; ++j) |
| 22 |
; |
| 23 |
|
| 24 |
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 25 |
#pragma omp interchange permutation(1 |
| 26 |
for (int i = 0; i < 7; ++i) |
| 27 |
for (int j = 0; j < 13; ++j) |
| 28 |
; |
| 29 |
|
| 30 |
// expected-error@+2 {{expected expression}} |
| 31 |
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 32 |
#pragma omp interchange permutation(1, |
| 33 |
for (int i = 0; i < 7; ++i) |
| 34 |
for (int j = 0; j < 13; ++j) |
| 35 |
; |
| 36 |
|
| 37 |
// expected-error@+1 {{expected expression}} |
| 38 |
#pragma omp interchange permutation(1,) |
| 39 |
for (int i = 0; i < 7; ++i) |
| 40 |
for (int j = 0; j < 13; ++j) |
| 41 |
; |
| 42 |
|
| 43 |
// expected-error@+2 {{expected expression}} |
| 44 |
// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 45 |
#pragma omp interchange permutation(5+ |
| 46 |
for (int i = 0; i < 7; ++i) |
| 47 |
for (int j = 0; j < 13; ++j) |
| 48 |
; |
| 49 |
|
| 50 |
// expected-error@+1 {{expected expression}} |
| 51 |
#pragma omp interchange permutation(5+) |
| 52 |
for (int i = 0; i < 7; ++i) |
| 53 |
for (int j = 0; j < 13; ++j) |
| 54 |
; |
| 55 |
|
| 56 |
// expected-error@+1 {{expected expression}} |
| 57 |
#pragma omp interchange permutation(for) |
| 58 |
for (int i = 0; i < 7; ++i) |
| 59 |
for (int j = 0; j < 13; ++j) |
| 60 |
; |
| 61 |
|
| 62 |
// expected-error@+1 {{permutation index must be at least 1 and at most 1}} |
| 63 |
#pragma omp interchange permutation(0) |
| 64 |
for (int i = 0; i < 7; ++i) |
| 65 |
for (int j = 0; j < 13; ++j) |
| 66 |
; |
| 67 |
|
| 68 |
// expected-error@+1 {{permutation index must be at least 1 and at most 2}} |
| 69 |
#pragma omp interchange permutation(1,3) |
| 70 |
for (int i = 0; i < 7; ++i) |
| 71 |
for (int j = 0; j < 13; ++j) |
| 72 |
; |
| 73 |
|
| 74 |
// expected-error@+1 {{index 1 must appear exactly once in the permutation clause}} |
| 75 |
#pragma omp interchange permutation(1,1) |
| 76 |
for (int i = 0; i < 7; ++i) |
| 77 |
for (int j = 0; j < 13; ++j) |
| 78 |
; |
| 79 |
|
| 80 |
// expected-error@+4 {{expression is not an integral constant expression}} |
| 81 |
// expected-note@+3 {{read of non-const variable 'a' is not allowed in a constant expression}} |
| 82 |
// expected-note@+1 {{declared here}} |
| 83 |
int a; |
| 84 |
#pragma omp interchange permutation(a) |
| 85 |
for (int i = 0; i < 7; ++i) |
| 86 |
for (int j = 0; j < 13; ++j) |
| 87 |
; |
| 88 |
|
| 89 |
// expected-warning@+1 {{extra tokens at the end of '#pragma omp interchange' are ignored}} |
| 90 |
#pragma omp interchange foo |
| 91 |
for (int i = 0; i < 7; ++i) |
| 92 |
for (int j = 0; j < 13; ++j) |
| 93 |
; |
| 94 |
|
| 95 |
// expected-error@+1 {{directive '#pragma omp interchange' cannot contain more than one 'permutation' clause}} |
| 96 |
#pragma omp interchange permutation(2,1) permutation(2,1) |
| 97 |
for (int i = 0; i < 7; ++i) |
| 98 |
for (int j = 0; j < 13; ++j) |
| 99 |
; |
| 100 |
|
| 101 |
// expected-error@+1 {{unexpected OpenMP clause 'collapse' in directive '#pragma omp interchange'}} |
| 102 |
#pragma omp interchange collapse(2) |
| 103 |
for (int i = 0; i < 7; ++i) |
| 104 |
for (int j = 0; j < 13; ++j) |
| 105 |
; |
| 106 |
|
| 107 |
{ |
| 108 |
// expected-error@+2 {{expected statement}} |
| 109 |
#pragma omp interchange |
| 110 |
} |
| 111 |
|
| 112 |
// expected-error@+2 {{statement after '#pragma omp interchange' must be a for loop}} |
| 113 |
#pragma omp interchange |
| 114 |
int b = 0; |
| 115 |
|
| 116 |
// expected-error@+3 {{statement after '#pragma omp interchange' must be a for loop}} |
| 117 |
#pragma omp interchange |
| 118 |
for (int i = 0; i < 7; ++i) |
| 119 |
; |
| 120 |
|
| 121 |
// expected-error@+2 {{statement after '#pragma omp interchange' must be a for loop}} |
| 122 |
#pragma omp interchange |
| 123 |
for (int i = 0; i < 7; ++i) { |
| 124 |
int k = 3; |
| 125 |
for (int j = 0; j < 7; ++j) |
| 126 |
; |
| 127 |
} |
| 128 |
|
| 129 |
// expected-error@+3 {{expected loop invariant expression}} |
| 130 |
#pragma omp interchange |
| 131 |
for (int i = 0; i < 7; ++i) |
| 132 |
for (int j = i; j < 7; ++j) |
| 133 |
; |
| 134 |
|
| 135 |
// expected-error@+3 {{expected loop invariant expression}} |
| 136 |
#pragma omp interchange |
| 137 |
for (int i = 0; i < 7; ++i) |
| 138 |
for (int j = 0; j < i; ++j) |
| 139 |
; |
| 140 |
|
| 141 |
// expected-error@+3 {{expected loop invariant expression}} |
| 142 |
#pragma omp interchange |
| 143 |
for (int i = 0; i < 7; ++i) |
| 144 |
for (int j = 0; j < i; ++j) |
| 145 |
; |
| 146 |
|
| 147 |
// expected-error@+6 {{expected 3 for loops after '#pragma omp for', but found only 2}} |
| 148 |
// expected-note@+1 {{as specified in 'collapse' clause}} |
| 149 |
#pragma omp for collapse(3) |
| 150 |
#pragma omp interchange |
| 151 |
for (int i = 0; i < 7; ++i) |
| 152 |
for (int j = 0; j < 13; ++j) |
| 153 |
; |
| 154 |
|
| 155 |
// expected-error@+2 {{statement after '#pragma omp interchange' must be a for loop}} |
| 156 |
#pragma omp interchange |
| 157 |
#pragma omp for |
| 158 |
for (int i = 0; i < 7; ++i) |
| 159 |
; |
| 160 |
|
| 161 |
// expected-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'j'}} |
| 162 |
#pragma omp interchange |
| 163 |
for (int i = 0; i < 7; ++i) |
| 164 |
for (int j = 0; j/3<7; ++j) |
| 165 |
; |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
template <typename T> |
| 171 |
static void templated_func() { |
| 172 |
// In a template context, but expression itself not instantiation-dependent |
| 173 |
|
| 174 |
// expected-error@+1 {{permutation index must be at least 1 and at most 2}} |
| 175 |
#pragma omp interchange permutation(0,1) |
| 176 |
for (int i = 0; i < 7; ++i) |
| 177 |
for (int j = 0; j<7; ++j) |
| 178 |
; |
| 179 |
|
| 180 |
// expected-error@+1 {{index 1 must appear exactly once in the permutation clause}} |
| 181 |
#pragma omp interchange permutation(1,1) |
| 182 |
for (int i = 0; i < 7; ++i) |
| 183 |
for (int j = 0; j<7; ++j) |
| 184 |
; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
template <int S> |
| 190 |
static void templated_func_value_dependent() { |
| 191 |
// expected-error@+1 {{permutation index must be at least 1 and at most 2}} |
| 192 |
#pragma omp interchange permutation(S,S+1) |
| 193 |
for (int i = 0; i < 7; ++i) |
| 194 |
for (int j = 0; j<7; ++j) |
| 195 |
; |
| 196 |
|
| 197 |
// expected-error@+1 {{index 1 must appear exactly once in the permutation clause}} |
| 198 |
#pragma omp interchange permutation(S+1,S+1) |
| 199 |
for (int i = 0; i < 7; ++i) |
| 200 |
for (int j = 0; j<7; ++j) |
| 201 |
; |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
template <typename T> |
| 206 |
static void templated_func_type_dependent() { |
| 207 |
constexpr T s = 0; |
| 208 |
|
| 209 |
// expected-error@+1 {{permutation index must be at least 1 and at most 2}} |
| 210 |
#pragma omp interchange permutation(s,s+1) |
| 211 |
for (int i = 0; i < 7; ++i) |
| 212 |
for (int j = 0; j<7; ++j) |
| 213 |
; |
| 214 |
|
| 215 |
// expected-error@+1 {{index 1 must appear exactly once in the permutation clause}} |
| 216 |
#pragma omp interchange permutation(s+1,s+1) |
| 217 |
for (int i = 0; i < 7; ++i) |
| 218 |
for (int j = 0; j<7; ++j) |
| 219 |
; |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
void template_inst() { |
| 224 |
// expected-note@+1 {{in instantiation of function template specialization 'templated_func<int>' requested here}} |
| 225 |
templated_func<int>(); |
| 226 |
// expected-note@+1 {{in instantiation of function template specialization 'templated_func_value_dependent<0>' requested here}} |
| 227 |
templated_func_value_dependent<0>(); |
| 228 |
// expected-note@+1 {{in instantiation of function template specialization 'templated_func_type_dependent<int>' requested here}} |
| 229 |
templated_func_type_dependent<int>(); |
| 230 |
} |
| 231 |
|