Debian Codegraph @

clang/test/SemaOpenACC/data-construct-copy-clause.c

raw
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 copy(LocalInt)
16 ;
17
18 // expected-warning@+1{{OpenACC clause name 'pcopy' is a deprecated clause name and is now an alias for 'copy'}}
19 #pragma acc data pcopy(LocalInt)
20 ;
21
22 // expected-warning@+1{{OpenACC clause name 'present_or_copy' is a deprecated clause name and is now an alias for 'copy'}}
23 #pragma acc data present_or_copy(LocalInt)
24 ;
25
26 // Valid cases:
27 #pragma acc data copy(LocalInt, LocalPointer, LocalArray)
28 ;
29 #pragma acc data copy(LocalArray[2:1])
30 ;
31
32 #pragma acc data copy(LocalComposite.ScalarMember, LocalComposite.ScalarMember)
33 ;
34
35 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
36 #pragma acc data copy(1 + IntParam)
37 ;
38
39 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
40 #pragma acc data copy(+IntParam)
41 ;
42
43 // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
44 #pragma acc data copy(PointerParam[2:])
45 ;
46
47 // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
48 #pragma acc data copy(ArrayParam[2:5])
49 ;
50
51 // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
52 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
53 #pragma acc data copy((float*)ArrayParam[2:5])
54 ;
55 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
56 #pragma acc data copy((float)ArrayParam[2])
57 ;
58
59 // expected-error@+2{{OpenACC 'enter data' construct must have at least one 'attach', 'copyin', or 'create' clause}}
60 // expected-error@+1{{OpenACC 'copy' clause is not valid on 'enter data' directive}}
61 #pragma acc enter data copy(LocalInt)
62 // expected-error@+2{{OpenACC 'exit data' construct must have at least one 'copyout', 'delete', or 'detach' clause}}
63 // expected-error@+1{{OpenACC 'pcopy' clause is not valid on 'exit data' directive}}
64 #pragma acc exit data pcopy(LocalInt)
65 // expected-error@+2{{OpenACC 'host_data' construct must have at least one 'use_device' clause}}
66 // expected-error@+1{{OpenACC 'present_or_copy' clause is not valid on 'host_data' directive}}
67 #pragma acc host_data present_or_copy(LocalInt)
68 ;
69 }
70 void ModList() {
71 int V1;
72 // expected-error@+2{{OpenACC 'readonly' modifier not valid on 'copy' clause}}
73 // expected-error@+1{{OpenACC 'zero' modifier not valid on 'copy' clause}}
74 #pragma acc data copy(always, alwaysin, alwaysout, zero, readonly: V1)
75 ;
76 // expected-error@+1{{OpenACC 'readonly' modifier not valid on 'copy' clause}}
77 #pragma acc data copy(readonly: V1)
78 ;
79 // expected-error@+1{{OpenACC 'zero' modifier not valid on 'copy' clause}}
80 #pragma acc data copy(zero: V1)
81 ;
82 #pragma acc data copy(capture:V1)
83 ;
84 #pragma acc data copy(always, alwaysin, alwaysout, capture: V1)
85 ;
86 }
87