60 lines · c
1// RUN: %clang_cc1 %s -fopenacc -verify2 3typedef struct IsComplete {4 struct S { int A; } CompositeMember;5 int ScalarMember;6 float ArrayMember[5];7 void *PointerMember;8} Complete;9void 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 firstprivate(LocalInt)16 while(1);17#pragma acc serial firstprivate(LocalInt)18 while(1);19 // expected-error@+1{{OpenACC 'firstprivate' clause is not valid on 'kernels' directive}}20#pragma acc kernels firstprivate(LocalInt)21 while(1);22 23 // Valid cases:24#pragma acc parallel firstprivate(LocalInt, LocalPointer, LocalArray)25 while(1);26#pragma acc parallel firstprivate(LocalArray[2:1])27 while(1);28 29#pragma acc parallel firstprivate(LocalComposite.ScalarMember, LocalComposite.ScalarMember)30 while(1);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 parallel firstprivate(1 + IntParam)34 while(1);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 parallel firstprivate(+IntParam)38 while(1);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 firstprivate(PointerParam[2:])42 while(1);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 parallel firstprivate(ArrayParam[2:5])46 while(1);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 firstprivate((float*)ArrayParam[2:5])51 while(1);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 parallel firstprivate((float)ArrayParam[2])54 while(1);55 56 // expected-error@+1{{OpenACC 'firstprivate' clause is not valid on 'loop' directive}}57#pragma acc loop firstprivate(LocalInt)58 for(int i = 5; i < 10;++i);59}60