Debian Codegraph @

clang/test/SemaOpenACC/combined-construct-firstprivate-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 parallel loop firstprivate(LocalInt)
16 for (int i = 5; i < 10; ++i);
17 #pragma acc serial loop firstprivate(LocalInt)
18 for (int i = 5; i < 10; ++i);
19 // expected-error@+1{{OpenACC 'firstprivate' clause is not valid on 'kernels loop' directive}}
20 #pragma acc kernels loop firstprivate(LocalInt)
21 for (int i = 5; i < 10; ++i);
22
23 // Valid cases:
24 #pragma acc parallel loop firstprivate(LocalInt, LocalPointer, LocalArray)
25 for (int i = 5; i < 10; ++i);
26 #pragma acc serial loop firstprivate(LocalArray[2:1])
27 for (int i = 5; i < 10; ++i);
28
29 #pragma acc parallel loop firstprivate(LocalComposite.ScalarMember, LocalComposite.ScalarMember)
30 for (int i = 5; i < 10; ++i);
31
32 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
33 #pragma acc serial loop firstprivate(1 + IntParam)
34 for (int i = 5; i < 10; ++i);
35
36 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
37 #pragma acc serial loop firstprivate(+IntParam)
38 for (int i = 5; i < 10; ++i);
39
40 // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
41 #pragma acc parallel loop firstprivate(PointerParam[2:])
42 for (int i = 5; i < 10; ++i);
43
44 // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
45 #pragma acc serial loop firstprivate(ArrayParam[2:5])
46 for (int i = 5; i < 10; ++i);
47
48 // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
49 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
50 #pragma acc parallel loop firstprivate((float*)ArrayParam[2:5])
51 for (int i = 5; i < 10; ++i);
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 serial loop firstprivate((float)ArrayParam[2])
54 for (int i = 5; i < 10; ++i);
55 }