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