| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -ast-dump | FileCheck %s | ||
|
|
||
| // Test this with PCH. | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -emit-pch -o %t %s | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -include-pch %t -ast-dump-all | FileCheck %s | ||
|
|
||
| #ifndef PCH_HELPER | ||
| #define PCH_HELPER | ||
|
|
||
| int Global; | ||
| short GlobalArray[5]; | ||
| void NormalUses(float *PointerParam) { | ||
| // CHECK: FunctionDecl{{.*}}NormalUses | ||
| // CHECK: ParmVarDecl | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop copy(GlobalArray) pcopy(PointerParam[Global]) present_or_copy(Global) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copy clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'short[5]' lvalue Var{{.*}}'GlobalArray' 'short[5]' | ||
| // CHECK-NEXT: pcopy clause | ||
| // CHECK-NEXT: ArraySubscriptExpr{{.*}}'float' lvalue | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'float *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'float *' lvalue ParmVar{{.*}}'PointerParam' 'float *' | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: present_or_copy clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK:NullStmt | ||
| } | ||
|
|
||
| template<auto &NTTP, typename T, typename U> | ||
| void TemplUses(T t, U u) { | ||
| // CHECK-NEXT: FunctionTemplateDecl | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}}referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 1 T | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 2 U | ||
| // CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void (T, U)' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced t 'T' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced u 'U' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop copy(t) pcopy(NTTP, u) present_or_copy(u[0:t]) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copy clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: pcopy clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: present_or_copy clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK:NullStmt | ||
|
|
||
| // Check the instantiated versions of the above. | ||
| // CHECK-NEXT: FunctionDecl{{.*}} used TemplUses 'void (int, int *)' implicit_instantiation | ||
| // CHECK-NEXT: TemplateArgument decl | ||
| // CHECK-NEXT: Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: TemplateArgument type 'int' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: TemplateArgument type 'int *' | ||
| // CHECK-NEXT: PointerType{{.*}} 'int *' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used t 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used u 'int *' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| // #pragma acc parallel copy(t) pcopy(NTTP, u) present_or_copy(u[0:t]) | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copy clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: pcopy clause | ||
| // CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: present_or_copy clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK:NullStmt | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr unsigned CEVar = 1; | ||
| int i; | ||
| TemplUses<CEVar>(i, &i); | ||
| } | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| void *PointerMember; | ||
| } Complete; | ||
| void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) { | ||
| int LocalInt; | ||
| short *LocalPointer; | ||
| float LocalArray[5]; | ||
| Complete LocalComposite; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop copy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop copy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop copy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'pcopy' is a deprecated clause name and is now an alias for 'copy'}} | ||
| #pragma acc parallel loop pcopy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'present_or_copy' is a deprecated clause name and is now an alias for 'copy'}} | ||
| #pragma acc parallel loop present_or_copy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop copy(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copy(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copy(LocalComposite.ScalarMember, LocalComposite.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copy(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop copy(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC 'copy' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop copy(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| // expected-error@+1{{OpenACC 'pcopy' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop pcopy(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| // expected-error@+1{{OpenACC 'present_or_copy' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop present_or_copy(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| enum SomeE{}; | ||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| SomeE EnumMember; | ||
| char *PointerMember; | ||
| } Complete; | ||
|
|
||
| void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete CompositeParam, int &IntParamRef) { | ||
| int LocalInt; | ||
| char *LocalPointer; | ||
| float LocalArray[5]; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop copy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop copy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop copy(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop copy(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copy(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| Complete LocalComposite2; | ||
| #pragma acc parallel loop copy(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copy(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop copy(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<typename T, unsigned I, typename V> | ||
| void TemplUses(T t, T (&arrayT)[I], V TemplComp) { | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy(+t) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#TEMPL_USES_INST{{in instantiation of}} | ||
| #pragma acc parallel loop copy(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copy(t, I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copy(arrayT) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copy(TemplComp) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copy(TemplComp.PointerMember[5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| int *Pointer; | ||
| #pragma acc parallel loop copy(Pointer[:I]) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copy(Pointer[:t]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copy(Pointer[1:]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<unsigned I, auto &NTTP_REF> | ||
| void NTTP() { | ||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#NTTP_INST{{in instantiation of}} | ||
| #pragma acc parallel loop copy(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copy(NTTP_REF) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr int NTTP_REFed = 1; | ||
| int i; | ||
| int Arr[5]; | ||
| Complete C; | ||
| TemplUses(i, Arr, C); // #TEMPL_USES_INST | ||
| NTTP<5, NTTP_REFed>(); // #NTTP_INST | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -ast-dump | FileCheck %s | ||
|
|
||
| // Test this with PCH. | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -emit-pch -o %t %s | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -include-pch %t -ast-dump-all | FileCheck %s | ||
|
|
||
| #ifndef PCH_HELPER | ||
| #define PCH_HELPER | ||
|
|
||
| int Global; | ||
| short GlobalArray[5]; | ||
| void NormalUses(float *PointerParam) { | ||
| // CHECK: FunctionDecl{{.*}}NormalUses | ||
| // CHECK: ParmVarDecl | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop copyin(GlobalArray) pcopyin(readonly:PointerParam[Global]) present_or_copyin(Global) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copyin clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'short[5]' lvalue Var{{.*}}'GlobalArray' 'short[5]' | ||
| // CHECK-NEXT: pcopyin clause : readonly | ||
| // CHECK-NEXT: ArraySubscriptExpr{{.*}}'float' lvalue | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'float *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'float *' lvalue ParmVar{{.*}}'PointerParam' 'float *' | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: present_or_copyin clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
| } | ||
|
|
||
| template<auto &NTTP, typename T, typename U> | ||
| void TemplUses(T t, U u) { | ||
| // CHECK-NEXT: FunctionTemplateDecl | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}}referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 1 T | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 2 U | ||
| // CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void (T, U)' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced t 'T' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced u 'U' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop copyin(t) pcopyin(readonly: NTTP, u) present_or_copyin(u[0:t]) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copyin clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: pcopyin clause : readonly | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: present_or_copyin clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
|
|
||
| // Check the instantiated versions of the above. | ||
| // CHECK-NEXT: FunctionDecl{{.*}} used TemplUses 'void (int, int *)' implicit_instantiation | ||
| // CHECK-NEXT: TemplateArgument decl | ||
| // CHECK-NEXT: Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: TemplateArgument type 'int' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: TemplateArgument type 'int *' | ||
| // CHECK-NEXT: PointerType{{.*}} 'int *' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used t 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used u 'int *' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| // #pragma acc parallel copyin(t) pcopyin(readonly: NTTP, u) present_or_copyin(u[0:t]) | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copyin clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: pcopyin clause : readonly | ||
| // CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: present_or_copyin clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr unsigned CEVar = 1; | ||
| int i; | ||
| TemplUses<CEVar>(i, &i); | ||
| } | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| void *PointerMember; | ||
| } Complete; | ||
| void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) { | ||
| int LocalInt; | ||
| short *LocalPointer; | ||
| float LocalArray[5]; | ||
| Complete LocalComposite; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop copyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop copyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop copyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'pcopyin' is a deprecated clause name and is now an alias for 'copyin'}} | ||
| #pragma acc parallel loop pcopyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'present_or_copyin' is a deprecated clause name and is now an alias for 'copyin'}} | ||
| #pragma acc parallel loop present_or_copyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop copyin(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyin(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyin(readonly:LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyin(LocalComposite.ScalarMember, LocalComposite.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copyin(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop copyin(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+2{{invalid tag 'invalid' on 'copyin' clause}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin(invalid:(float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC 'copyin' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop copyin(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| // expected-error@+1{{OpenACC 'pcopyin' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop pcopyin(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| // expected-error@+1{{OpenACC 'present_or_copyin' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop present_or_copyin(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| enum SomeE{}; | ||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| SomeE EnumMember; | ||
| char *PointerMember; | ||
| } Complete; | ||
|
|
||
| void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete CompositeParam, int &IntParamRef) { | ||
| int LocalInt; | ||
| char *LocalPointer; | ||
| float LocalArray[5]; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop copyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop copyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop copyin(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop copyin(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyin(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| Complete LocalComposite2; | ||
| #pragma acc parallel loop copyin(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copyin(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop copyin(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<typename T, unsigned I, typename V> | ||
| void TemplUses(T t, T (&arrayT)[I], V TemplComp) { | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin(+t) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#TEMPL_USES_INST{{in instantiation of}} | ||
| #pragma acc parallel loop copyin(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyin(t, I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyin(arrayT) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyin(TemplComp) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyin(TemplComp.PointerMember[5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| int *Pointer; | ||
| #pragma acc parallel loop copyin(Pointer[:I]) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyin(Pointer[:t]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copyin(Pointer[1:]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<unsigned I, auto &NTTP_REF> | ||
| void NTTP() { | ||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#NTTP_INST{{in instantiation of}} | ||
| #pragma acc parallel loop copyin(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyin(NTTP_REF) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr int NTTP_REFed = 1; | ||
| int i; | ||
| int Arr[5]; | ||
| Complete C; | ||
| TemplUses(i, Arr, C); // #TEMPL_USES_INST | ||
| NTTP<5, NTTP_REFed>(); // #NTTP_INST | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -ast-dump | FileCheck %s | ||
|
|
||
| // Test this with PCH. | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -emit-pch -o %t %s | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -include-pch %t -ast-dump-all | FileCheck %s | ||
|
|
||
| #ifndef PCH_HELPER | ||
| #define PCH_HELPER | ||
|
|
||
| int Global; | ||
| short GlobalArray[5]; | ||
| void NormalUses(float *PointerParam) { | ||
| // CHECK: FunctionDecl{{.*}}NormalUses | ||
| // CHECK: ParmVarDecl | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop copyout(GlobalArray) pcopyout(zero:PointerParam[Global]) present_or_copyout(Global) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copyout clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'short[5]' lvalue Var{{.*}}'GlobalArray' 'short[5]' | ||
| // CHECK-NEXT: pcopyout clause : zero | ||
| // CHECK-NEXT: ArraySubscriptExpr{{.*}}'float' lvalue | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'float *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'float *' lvalue ParmVar{{.*}}'PointerParam' 'float *' | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: present_or_copyout clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: For | ||
| // CHECK: NullStmt | ||
| } | ||
|
|
||
| template<auto &NTTP, typename T, typename U> | ||
| void TemplUses(T t, U u) { | ||
| // CHECK-NEXT: FunctionTemplateDecl | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}}referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 1 T | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 2 U | ||
| // CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void (T, U)' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced t 'T' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced u 'U' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop copyout(t) pcopyout(zero: NTTP, u) present_or_copyout(u[0:t]) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copyout clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: pcopyout clause : zero | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: present_or_copyout clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
|
|
||
| // Check the instantiated versions of the above. | ||
| // CHECK-NEXT: FunctionDecl{{.*}} used TemplUses 'void (int, int *)' implicit_instantiation | ||
| // CHECK-NEXT: TemplateArgument decl | ||
| // CHECK-NEXT: Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: TemplateArgument type 'int' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: TemplateArgument type 'int *' | ||
| // CHECK-NEXT: PointerType{{.*}} 'int *' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used t 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used u 'int *' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| // #pragma acc parallel copyout(t) pcopyout(zero: NTTP, u) present_or_copyout(u[0:t]) | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: copyout clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: pcopyout clause : zero | ||
| // CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: present_or_copyout clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr unsigned CEVar = 1; | ||
| int i; | ||
| TemplUses<CEVar>(i, &i); | ||
| } | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| void *PointerMember; | ||
| } Complete; | ||
| void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) { | ||
| int LocalInt; | ||
| short *LocalPointer; | ||
| float LocalArray[5]; | ||
| Complete LocalComposite; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop copyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop copyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop copyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'pcopyout' is a deprecated clause name and is now an alias for 'copyout'}} | ||
| #pragma acc parallel loop pcopyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'present_or_copyout' is a deprecated clause name and is now an alias for 'copyout'}} | ||
| #pragma acc parallel loop present_or_copyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop copyout(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyout(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyout(zero:LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyout(LocalComposite.ScalarMember, LocalComposite.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copyout(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop copyout(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+2{{invalid tag 'invalid' on 'copyout' clause}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout(invalid:(float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC 'copyout' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop copyout(LocalInt) | ||
| for(int i = 0; i < 6;++i); | ||
| // expected-error@+1{{OpenACC 'pcopyout' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop pcopyout(LocalInt) | ||
| for(int i = 0; i < 6;++i); | ||
| // expected-error@+1{{OpenACC 'present_or_copyout' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop present_or_copyout(LocalInt) | ||
| for(int i = 0; i < 6;++i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| enum SomeE{}; | ||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| SomeE EnumMember; | ||
| char *PointerMember; | ||
| } Complete; | ||
|
|
||
| void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete CompositeParam, int &IntParamRef) { | ||
| int LocalInt; | ||
| char *LocalPointer; | ||
| float LocalArray[5]; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop copyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop copyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop copyout(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop copyout(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyout(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| Complete LocalComposite2; | ||
| #pragma acc parallel loop copyout(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copyout(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop copyout(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<typename T, unsigned I, typename V> | ||
| void TemplUses(T t, T (&arrayT)[I], V TemplComp) { | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout(+t) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#TEMPL_USES_INST{{in instantiation of}} | ||
| #pragma acc parallel loop copyout(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop copyout(t, I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyout(arrayT) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyout(TemplComp) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyout(TemplComp.PointerMember[5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| int *Pointer; | ||
| #pragma acc parallel loop copyout(Pointer[:I]) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop copyout(Pointer[:t]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop copyout(Pointer[1:]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<unsigned I, auto &NTTP_REF> | ||
| void NTTP() { | ||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#NTTP_INST{{in instantiation of}} | ||
| #pragma acc parallel loop copyout(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop copyout(NTTP_REF) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr int NTTP_REFed = 1; | ||
| int i; | ||
| int Arr[5]; | ||
| Complete C; | ||
| TemplUses(i, Arr, C); // #TEMPL_USES_INST | ||
| NTTP<5, NTTP_REFed>(); // #NTTP_INST | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -ast-dump | FileCheck %s | ||
|
|
||
| // Test this with PCH. | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -emit-pch -o %t %s | ||
| // RUN: %clang_cc1 %s -fopenacc -Wno-openacc-deprecated-clause-alias -include-pch %t -ast-dump-all | FileCheck %s | ||
|
|
||
| #ifndef PCH_HELPER | ||
| #define PCH_HELPER | ||
|
|
||
| int Global; | ||
| short GlobalArray[5]; | ||
| void NormalUses(float *PointerParam) { | ||
| // CHECK: FunctionDecl{{.*}}NormalUses | ||
| // CHECK: ParmVarDecl | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop create(GlobalArray) pcreate(zero:PointerParam[Global]) present_or_create(Global) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: create clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'short[5]' lvalue Var{{.*}}'GlobalArray' 'short[5]' | ||
| // CHECK-NEXT: pcreate clause : zero | ||
| // CHECK-NEXT: ArraySubscriptExpr{{.*}}'float' lvalue | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'float *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'float *' lvalue ParmVar{{.*}}'PointerParam' 'float *' | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: present_or_create clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
| } | ||
|
|
||
| template<auto &NTTP, typename T, typename U> | ||
| void TemplUses(T t, U u) { | ||
| // CHECK-NEXT: FunctionTemplateDecl | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl {{.*}}referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 1 T | ||
| // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 2 U | ||
| // CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void (T, U)' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced t 'T' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} referenced u 'U' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| #pragma acc parallel loop create(t) pcreate(zero: NTTP, u) present_or_create(u[0:t]) | ||
| for (unsigned i = 0; i < 5; ++i); | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: create clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: pcreate clause : zero | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: present_or_create clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
|
|
||
| // Check the instantiated versions of the above. | ||
| // CHECK-NEXT: FunctionDecl{{.*}} used TemplUses 'void (int, int *)' implicit_instantiation | ||
| // CHECK-NEXT: TemplateArgument decl | ||
| // CHECK-NEXT: Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: TemplateArgument type 'int' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: TemplateArgument type 'int *' | ||
| // CHECK-NEXT: PointerType{{.*}} 'int *' | ||
| // CHECK-NEXT: BuiltinType{{.*}} 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used t 'int' | ||
| // CHECK-NEXT: ParmVarDecl{{.*}} used u 'int *' | ||
| // CHECK-NEXT: CompoundStmt | ||
|
|
||
| // #pragma acc parallel create(t) pcreate(zero: NTTP, u) present_or_create(u[0:t]) | ||
| // CHECK-NEXT: OpenACCCombinedConstruct{{.*}} parallel loop | ||
| // CHECK-NEXT: create clause | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: pcreate clause : zero | ||
| // CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue | ||
| // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int' | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: present_or_create clause | ||
| // CHECK-NEXT: ArraySectionExpr | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int *' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *' | ||
| // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 0 | ||
| // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
| // CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int' | ||
| // CHECK-NEXT: ForStmt | ||
| // CHECK: NullStmt | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr unsigned CEVar = 1; | ||
| int i; | ||
| TemplUses<CEVar>(i, &i); | ||
| } | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| void *PointerMember; | ||
| } Complete; | ||
| void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) { | ||
| int LocalInt; | ||
| short *LocalPointer; | ||
| float LocalArray[5]; | ||
| Complete LocalComposite; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop create(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop create(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop create(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'pcreate' is a deprecated clause name and is now an alias for 'create'}} | ||
| #pragma acc parallel loop pcreate(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-warning@+1{{OpenACC clause name 'present_or_create' is a deprecated clause name and is now an alias for 'create'}} | ||
| #pragma acc parallel loop present_or_create(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop create(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop create(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop create(zero:LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop create(LocalComposite.ScalarMember, LocalComposite.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop create(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop create(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+2{{invalid tag 'invalid' on 'create' clause}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create(invalid:(float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC 'create' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop create(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| // expected-error@+1{{OpenACC 'pcreate' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop pcreate(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| // expected-error@+1{{OpenACC 'present_or_create' clause is not valid on 'loop' directive}} | ||
| #pragma acc loop present_or_create(LocalInt) | ||
| for(int i = 5; i < 10;++i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
|
|
||
| // RUN: %clang_cc1 %s -fopenacc -verify | ||
|
|
||
| enum SomeE{}; | ||
| typedef struct IsComplete { | ||
| struct S { int A; } CompositeMember; | ||
| int ScalarMember; | ||
| float ArrayMember[5]; | ||
| SomeE EnumMember; | ||
| char *PointerMember; | ||
| } Complete; | ||
|
|
||
| void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete CompositeParam, int &IntParamRef) { | ||
| int LocalInt; | ||
| char *LocalPointer; | ||
| float LocalArray[5]; | ||
| // Check Appertainment: | ||
| #pragma acc parallel loop create(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc serial loop create(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc kernels loop create(LocalInt) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // Valid cases: | ||
| #pragma acc parallel loop create(LocalInt, LocalPointer, LocalArray) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop create(LocalArray[2:1]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| Complete LocalComposite2; | ||
| #pragma acc parallel loop create(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create(1 + IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create(+IntParam) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop create(PointerParam[2:]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| #pragma acc parallel loop create(ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create((float*)ArrayParam[2:5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create((float)ArrayParam[2]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<typename T, unsigned I, typename V> | ||
| void TemplUses(T t, T (&arrayT)[I], V TemplComp) { | ||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create(+t) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#TEMPL_USES_INST{{in instantiation of}} | ||
| #pragma acc parallel loop create(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| #pragma acc parallel loop create(t, I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop create(arrayT) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop create(TemplComp) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop create(TemplComp.PointerMember[5]) | ||
| for(int i = 0; i < 5; ++i); | ||
| int *Pointer; | ||
| #pragma acc parallel loop create(Pointer[:I]) | ||
| for(int i = 0; i < 5; ++i); | ||
| #pragma acc parallel loop create(Pointer[:t]) | ||
| for(int i = 0; i < 5; ++i); | ||
| // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} | ||
| #pragma acc parallel loop create(Pointer[1:]) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| template<unsigned I, auto &NTTP_REF> | ||
| void NTTP() { | ||
| // NTTP's are only valid if it is a reference to something. | ||
| // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} | ||
| // expected-note@#NTTP_INST{{in instantiation of}} | ||
| #pragma acc parallel loop create(I) | ||
| for(int i = 0; i < 5; ++i); | ||
|
|
||
| #pragma acc parallel loop create(NTTP_REF) | ||
| for(int i = 0; i < 5; ++i); | ||
| } | ||
|
|
||
| void Inst() { | ||
| static constexpr int NTTP_REFed = 1; | ||
| int i; | ||
| int Arr[5]; | ||
| Complete C; | ||
| TemplUses(i, Arr, C); // #TEMPL_USES_INST | ||
| NTTP<5, NTTP_REFed>(); // #NTTP_INST | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // RUN: %clangxx -fsanitize=realtime %s -o %t | ||
| // RUN: %env_rtsan_opts="halt_on_error=false" %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-RTSAN,CHECK | ||
|
|
||
| // RUN: %clangxx %s -o %t | ||
| // RUN: %run %t 2>&1 | FileCheck %s | ||
|
|
||
| // UNSUPPORTED: ios | ||
|
|
||
| // Intent: Ensure the `syscall` call behaves in the same way with/without the | ||
| // sanitizer disabled | ||
|
|
||
| #include <fcntl.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <sys/syscall.h> | ||
| #include <sys/types.h> | ||
| #include <unistd.h> | ||
|
|
||
| const char *GetTemporaryFilePath() { return "/tmp/rtsan_syscall_test.txt"; } | ||
|
|
||
| void custom_assert(bool condition, const char *message) { | ||
| if (!condition) { | ||
| fprintf(stderr, "ASSERTION FAILED: %s\n", message); | ||
| exit(1); | ||
| } | ||
| } | ||
|
|
||
| class ScopedFileCleanup { | ||
| public: | ||
| [[nodiscard]] ScopedFileCleanup() = default; | ||
| ~ScopedFileCleanup() { | ||
| if (access(GetTemporaryFilePath(), F_OK) != -1) | ||
| unlink(GetTemporaryFilePath()); | ||
| } | ||
| }; | ||
|
|
||
| // Apple has deprecated `syscall`, ignore that error | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
| int main() [[clang::nonblocking]] { | ||
| ScopedFileCleanup cleanup; | ||
|
|
||
| { | ||
| int fd = syscall(SYS_openat, AT_FDCWD, GetTemporaryFilePath(), | ||
| O_CREAT | O_WRONLY, 0644); | ||
|
|
||
| custom_assert(fd != -1, "Failed to open file - write"); | ||
|
|
||
| int written = syscall(SYS_write, fd, "Hello, world!", 13); | ||
| custom_assert(written == 13, "Failed to write to file"); | ||
|
|
||
| custom_assert(syscall(SYS_close, fd) == 0, "Failed to close file - write"); | ||
| } | ||
|
|
||
| { | ||
| int fd = syscall(SYS_openat, AT_FDCWD, GetTemporaryFilePath(), O_RDONLY); | ||
| custom_assert(fd != -1, "Failed to open file - read"); | ||
|
|
||
| char buffer[13]; | ||
| int read = syscall(SYS_read, fd, buffer, 13); | ||
| custom_assert(read == 13, "Failed to read from file"); | ||
|
|
||
| custom_assert(memcmp(buffer, "Hello, world!", 13) == 0, | ||
| "Read data does not match written data"); | ||
|
|
||
| custom_assert(syscall(SYS_close, fd) == 0, "Failed to close file - read"); | ||
| } | ||
|
|
||
| unlink(GetTemporaryFilePath()); | ||
| printf("DONE\n"); | ||
| } | ||
| #pragma clang diagnostic pop | ||
|
|
||
| // CHECK-NOT: ASSERTION FAILED | ||
| // CHECK-RTSAN-COUNT-6: Intercepted call to real-time unsafe function `syscall` | ||
|
|
||
| // CHECK: DONE |