| 1 |
// RUN: %clang_cc1 %s -verify -fopenacc |
| 2 |
|
| 3 |
struct S { |
| 4 |
int foo; |
| 5 |
char Array[1]; |
| 6 |
}; |
| 7 |
char *getArrayPtr(); |
| 8 |
void func() { |
| 9 |
char Array[10]; |
| 10 |
char *ArrayPtr = getArrayPtr(); |
| 11 |
int *readonly; |
| 12 |
struct S s; |
| 13 |
|
| 14 |
for (int i = 0; i < 10; ++i) { |
| 15 |
// expected-error@+1{{expected '('}} |
| 16 |
#pragma acc cache |
| 17 |
} |
| 18 |
|
| 19 |
for (int i = 0; i < 10; ++i) { |
| 20 |
// expected-error@+2{{expected '('}} |
| 21 |
// expected-error@+1{{invalid OpenACC clause 'clause'}} |
| 22 |
#pragma acc cache clause list |
| 23 |
} |
| 24 |
|
| 25 |
for (int i = 0; i < 10; ++i) { |
| 26 |
// expected-error@+1{{expected expression}} |
| 27 |
#pragma acc cache() |
| 28 |
} |
| 29 |
|
| 30 |
for (int i = 0; i < 10; ++i) { |
| 31 |
// expected-error@+2{{expected expression}} |
| 32 |
// expected-error@+1{{invalid OpenACC clause 'clause'}} |
| 33 |
#pragma acc cache() clause-list |
| 34 |
} |
| 35 |
|
| 36 |
for (int i = 0; i < 10; ++i) { |
| 37 |
// expected-error@+2{{expected ')'}} |
| 38 |
// expected-note@+1{{to match this '('}} |
| 39 |
#pragma acc cache( |
| 40 |
} |
| 41 |
|
| 42 |
for (int i = 0; i < 10; ++i) { |
| 43 |
// expected-error@+3{{use of undeclared identifier 'invalid'}} |
| 44 |
// expected-error@+2{{expected ')'}} |
| 45 |
// expected-note@+1{{to match this '('}} |
| 46 |
#pragma acc cache(invalid |
| 47 |
} |
| 48 |
|
| 49 |
#pragma acc loop |
| 50 |
for (int i = 0; i < 10; ++i) { |
| 51 |
// expected-error@+3{{expected ')'}} |
| 52 |
// expected-note@+2{{to match this '('}} |
| 53 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 54 |
#pragma acc cache(ArrayPtr |
| 55 |
} |
| 56 |
|
| 57 |
for (int i = 0; i < 10; ++i) { |
| 58 |
// expected-error@+1{{use of undeclared identifier 'invalid'}} |
| 59 |
#pragma acc cache(invalid) |
| 60 |
} |
| 61 |
|
| 62 |
#pragma acc loop |
| 63 |
for (int i = 0; i < 10; ++i) { |
| 64 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 65 |
#pragma acc cache(ArrayPtr) |
| 66 |
} |
| 67 |
|
| 68 |
#pragma acc loop |
| 69 |
for (int i = 0; i < 10; ++i) { |
| 70 |
// expected-error@+5{{expected expression}} |
| 71 |
// expected-error@+4{{expected ']'}} |
| 72 |
// expected-note@+3{{to match this '['}} |
| 73 |
// expected-error@+2{{expected ')'}} |
| 74 |
// expected-note@+1{{to match this '('}} |
| 75 |
#pragma acc cache(ArrayPtr[ |
| 76 |
} |
| 77 |
|
| 78 |
#pragma acc loop |
| 79 |
for (int i = 0; i < 10; ++i) { |
| 80 |
// expected-error@+3{{expected expression}} |
| 81 |
// expected-error@+2{{expected ']'}} |
| 82 |
// expected-note@+1{{to match this '['}} |
| 83 |
#pragma acc cache(ArrayPtr[, 5) |
| 84 |
} |
| 85 |
|
| 86 |
#pragma acc loop |
| 87 |
for (int i = 0; i < 10; ++i) { |
| 88 |
// expected-error@+3{{expected expression}} |
| 89 |
// expected-error@+2{{expected ']'}} |
| 90 |
// expected-note@+1{{to match this '['}} |
| 91 |
#pragma acc cache(Array[) |
| 92 |
} |
| 93 |
|
| 94 |
#pragma acc loop |
| 95 |
for (int i = 0; i < 10; ++i) { |
| 96 |
#pragma acc cache(Array[*readonly]) |
| 97 |
} |
| 98 |
|
| 99 |
#pragma acc loop |
| 100 |
for (int i = 0; i < 10; ++i) { |
| 101 |
// expected-error@+5{{expected expression}} |
| 102 |
// expected-error@+4{{expected ']'}} |
| 103 |
// expected-note@+3{{to match this '['}} |
| 104 |
// expected-error@+2{{expected ')'}} |
| 105 |
// expected-note@+1{{to match this '('}} |
| 106 |
#pragma acc cache(Array[*readonly: |
| 107 |
} |
| 108 |
|
| 109 |
#pragma acc loop |
| 110 |
for (int i = 0; i < 10; ++i) { |
| 111 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 112 |
#pragma acc cache(readonly) |
| 113 |
} |
| 114 |
|
| 115 |
#pragma acc loop |
| 116 |
for (int i = 0; i < 10; ++i) { |
| 117 |
// expected-error@+2{{invalid tag 'devnum' on 'cache' directive}} |
| 118 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 119 |
#pragma acc cache(devnum:ArrayPtr) |
| 120 |
} |
| 121 |
|
| 122 |
#pragma acc loop |
| 123 |
for (int i = 0; i < 10; ++i) { |
| 124 |
// expected-error@+2{{invalid tag 'invalid' on 'cache' directive}} |
| 125 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 126 |
#pragma acc cache(invalid:ArrayPtr) |
| 127 |
} |
| 128 |
|
| 129 |
#pragma acc loop |
| 130 |
for (int i = 0; i < 10; ++i) { |
| 131 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 132 |
#pragma acc cache(readonly:ArrayPtr) |
| 133 |
} |
| 134 |
|
| 135 |
#pragma acc loop |
| 136 |
for (int i = 0; i < 10; ++i) { |
| 137 |
#pragma acc cache(readonly:ArrayPtr[5:1]) |
| 138 |
} |
| 139 |
|
| 140 |
#pragma acc loop |
| 141 |
for (int i = 0; i < 10; ++i) { |
| 142 |
#pragma acc cache(readonly:ArrayPtr[5:*readonly]) |
| 143 |
} |
| 144 |
|
| 145 |
#pragma acc loop |
| 146 |
for (int i = 0; i < 10; ++i) { |
| 147 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 148 |
#pragma acc cache(readonly:ArrayPtr[5:*readonly], Array) |
| 149 |
} |
| 150 |
|
| 151 |
#pragma acc loop |
| 152 |
for (int i = 0; i < 10; ++i) { |
| 153 |
#pragma acc cache(readonly:ArrayPtr[5:*readonly], Array[*readonly:3]) |
| 154 |
} |
| 155 |
|
| 156 |
#pragma acc loop |
| 157 |
for (int i = 0; i < 10; ++i) { |
| 158 |
#pragma acc cache(readonly:ArrayPtr[5 + 0:*readonly], Array[*readonly + 0:3]) |
| 159 |
} |
| 160 |
|
| 161 |
#pragma acc loop |
| 162 |
for (int i = 0; i < 10; ++i) { |
| 163 |
// expected-error@+3{{expected expression}} |
| 164 |
// expected-error@+2{{expected ')'}} |
| 165 |
// expected-note@+1{{to match this '('}} |
| 166 |
#pragma acc cache(readonly:ArrayPtr[5:*readonly], |
| 167 |
} |
| 168 |
|
| 169 |
#pragma acc loop |
| 170 |
for (int i = 0; i < 10; ++i) { |
| 171 |
// expected-error@+1{{expected expression}} |
| 172 |
#pragma acc cache(readonly:ArrayPtr[5:*readonly],) |
| 173 |
} |
| 174 |
|
| 175 |
#pragma acc loop |
| 176 |
for (int i = 0; i < 10; ++i) { |
| 177 |
// expected-warning@+1{{left operand of comma operator has no effect}} |
| 178 |
#pragma acc cache(readonly:ArrayPtr[5,6:*readonly]) |
| 179 |
} |
| 180 |
|
| 181 |
#pragma acc loop |
| 182 |
for (int i = 0; i < 10; ++i) { |
| 183 |
// expected-warning@+1{{left operand of comma operator has no effect}} |
| 184 |
#pragma acc cache(readonly:ArrayPtr[5:3, *readonly], ArrayPtr[0]) |
| 185 |
} |
| 186 |
|
| 187 |
#pragma acc loop |
| 188 |
for (int i = 0; i < 10; ++i) { |
| 189 |
// expected-error@+1{{OpenACC variable in 'cache' directive is not a valid sub-array or array element}} |
| 190 |
#pragma acc cache(readonly:s.foo) |
| 191 |
} |
| 192 |
|
| 193 |
#pragma acc loop |
| 194 |
for (int i = 0; i < 10; ++i) { |
| 195 |
// expected-warning@+1{{left operand of comma operator has no effect}} |
| 196 |
#pragma acc cache(readonly:s.Array[1,2]) |
| 197 |
} |
| 198 |
} |