| 1 |
// RUN: %clang_cc1 %s -fopenacc -verify |
| 2 |
|
| 3 |
typedef struct IsComplete { |
| 4 |
struct S { int A; } CompositeMember; |
| 5 |
int ScalarMember; |
| 6 |
float ArrayMember[5]; |
| 7 |
void *PointerMember; |
| 8 |
} Complete; |
| 9 |
void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) { |
| 10 |
int LocalInt; |
| 11 |
short *LocalPointer; |
| 12 |
float LocalArray[5]; |
| 13 |
Complete LocalComposite; |
| 14 |
// Check Appertainment: |
| 15 |
#pragma acc data default(none) present(LocalInt) |
| 16 |
; |
| 17 |
|
| 18 |
// Valid cases: |
| 19 |
#pragma acc data default(none) present(LocalInt, LocalPointer, LocalArray) |
| 20 |
; |
| 21 |
#pragma acc data default(none) present(LocalArray[2:1]) |
| 22 |
; |
| 23 |
|
| 24 |
#pragma acc data default(none) present(LocalComposite.ScalarMember, LocalComposite.ScalarMember) |
| 25 |
; |
| 26 |
|
| 27 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 28 |
#pragma acc data default(none) present(1 + IntParam) |
| 29 |
; |
| 30 |
|
| 31 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 32 |
#pragma acc data default(none) present(+IntParam) |
| 33 |
; |
| 34 |
|
| 35 |
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 36 |
#pragma acc data default(none) present(PointerParam[2:]) |
| 37 |
; |
| 38 |
|
| 39 |
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 40 |
#pragma acc data default(none) present(ArrayParam[2:5]) |
| 41 |
; |
| 42 |
|
| 43 |
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 44 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 45 |
#pragma acc data default(none) present((float*)ArrayParam[2:5]) |
| 46 |
; |
| 47 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 48 |
#pragma acc data default(none) present((float)ArrayParam[2]) |
| 49 |
; |
| 50 |
|
| 51 |
// expected-error@+1{{OpenACC 'present' clause is not valid on 'enter data' directive}} |
| 52 |
#pragma acc enter data copyin(LocalInt) present(LocalInt) |
| 53 |
// expected-error@+1{{OpenACC 'present' clause is not valid on 'exit data' directive}} |
| 54 |
#pragma acc exit data copyout(LocalInt) present(LocalInt) |
| 55 |
// expected-error@+1{{OpenACC 'present' clause is not valid on 'host_data' directive}} |
| 56 |
#pragma acc host_data use_device(LocalInt) present(LocalInt) |
| 57 |
; |
| 58 |
} |