| 1 |
// RUN: %clang_cc1 %s -fopenacc -verify -Wopenacc-extension |
| 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 host_data use_device(LocalInt) |
| 16 |
|
| 17 |
// Valid cases: |
| 18 |
#pragma acc host_data use_device(LocalInt, LocalPointer, LocalArray) |
| 19 |
; |
| 20 |
; |
| 21 |
// expected-error@+2{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}} |
| 22 |
// expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}} |
| 23 |
#pragma acc host_data use_device(LocalComposite.ScalarMember, LocalComposite.ScalarMember) |
| 24 |
; |
| 25 |
|
| 26 |
// expected-warning@+1{{sub-array as a variable in 'use_device' clause is not a valid variable name or array name}} |
| 27 |
#pragma acc host_data use_device(LocalArray[2:1]) |
| 28 |
|
| 29 |
// expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}} |
| 30 |
#pragma acc host_data use_device(1 + IntParam) |
| 31 |
; |
| 32 |
|
| 33 |
// expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}} |
| 34 |
#pragma acc host_data use_device(+IntParam) |
| 35 |
; |
| 36 |
|
| 37 |
// expected-error@+2{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 38 |
// expected-warning@+1{{sub-array as a variable in 'use_device' clause is not a valid variable name or array name}} |
| 39 |
#pragma acc host_data use_device(PointerParam[2:]) |
| 40 |
; |
| 41 |
|
| 42 |
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 43 |
// expected-warning@+1{{sub-array as a variable in 'use_device' clause is not a valid variable name or array name}} |
| 44 |
#pragma acc host_data use_device(ArrayParam[2:5]) |
| 45 |
; |
| 46 |
|
| 47 |
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 48 |
// expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}} |
| 49 |
#pragma acc host_data use_device((float*)ArrayParam[2:5]) |
| 50 |
; |
| 51 |
// expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}} |
| 52 |
#pragma acc host_data use_device((float)ArrayParam[2]) |
| 53 |
; |
| 54 |
|
| 55 |
// expected-error@+2{{OpenACC 'data' construct must have at least one 'attach', 'copy', 'copyin', 'copyout', 'create', 'default', 'deviceptr', 'no_create', or 'present' clause}} |
| 56 |
// expected-error@+1{{OpenACC 'use_device' clause is not valid on 'data' directive}} |
| 57 |
#pragma acc data use_device(LocalInt) |
| 58 |
; |
| 59 |
// expected-error@+2{{OpenACC 'enter data' construct must have at least one 'attach', 'copyin', or 'create' clause}} |
| 60 |
// expected-error@+1{{OpenACC 'use_device' clause is not valid on 'enter data' directive}} |
| 61 |
#pragma acc enter data use_device(LocalInt) |
| 62 |
// expected-error@+2{{OpenACC 'exit data' construct must have at least one 'copyout', 'delete', or 'detach' clause}} |
| 63 |
// expected-error@+1{{OpenACC 'use_device' clause is not valid on 'exit data' directive}} |
| 64 |
#pragma acc exit data use_device(LocalInt) |
| 65 |
} |