Author: erichkeane Date: 2024-11-27T09:55:19-08:00 New Revision: 35a5c7129a32f7eedf2d1913447c53cee96eab13
URL: https://github.com/llvm/llvm-project/commit/35a5c7129a32f7eedf2d1913447c53cee96eab13 DIFF: https://github.com/llvm/llvm-project/commit/35a5c7129a32f7eedf2d1913447c53cee96eab13.diff LOG: [OpenACC] Add tests forgotten in 969b7658fe Added: clang/test/SemaOpenACC/combined-construct-wait-ast.cpp clang/test/SemaOpenACC/combined-construct-wait-clause.c clang/test/SemaOpenACC/combined-construct-wait-clause.cpp Modified: Removed: ################################################################################ diff --git a/clang/test/SemaOpenACC/combined-construct-wait-ast.cpp b/clang/test/SemaOpenACC/combined-construct-wait-ast.cpp new file mode 100644 index 00000000000000..0620901fd9fdb2 --- /dev/null +++ b/clang/test/SemaOpenACC/combined-construct-wait-ast.cpp @@ -0,0 +1,239 @@ +// RUN: %clang_cc1 %s -fopenacc -ast-dump | FileCheck %s + +// Test this with PCH. +// RUN: %clang_cc1 %s -fopenacc -emit-pch -o %t %s +// RUN: %clang_cc1 %s -fopenacc -include-pch %t -ast-dump-all | FileCheck %s + +#ifndef PCH_HELPER +#define PCH_HELPER + +int some_int(); +long some_long(); + +void NormalUses() { + // CHECK: FunctionDecl{{.*}}NormalUses + // CHECK-NEXT: CompoundStmt + +#pragma acc parallel loop wait + for (int i = 0; i < 5; ++i) {} + // CHECK-NEXT: OpenACCCombinedConstruct{{.*}}parallel loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ForStmt +#pragma acc serial loop wait() + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}serial loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ForStmt +#pragma acc kernels loop wait(some_int(), some_long()) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}kernels loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'long' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'long (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'long ()' lvalue Function{{.*}} 'some_long' 'long ()' + // CHECK-NEXT: ForStmt +#pragma acc parallel loop wait(queues:some_int(), some_long()) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}parallel loop + // CHECK-NEXT: wait clause has queues tag + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'long' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'long (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'long ()' lvalue Function{{.*}} 'some_long' 'long ()' + // CHECK-NEXT: ForStmt +#pragma acc serial loop wait(devnum: some_int() :some_int(), some_long()) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}serial loop + // CHECK-NEXT: wait clause has devnum + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'long' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'long (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'long ()' lvalue Function{{.*}} 'some_long' 'long ()' + // CHECK-NEXT: ForStmt +#pragma acc kernels loop wait(devnum: some_int() : queues :some_int(), some_long()) wait(devnum: some_int() : queues :some_int(), some_long()) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}kernels loop + // CHECK-NEXT: wait clause has devnum has queues tag + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'long' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'long (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'long ()' lvalue Function{{.*}} 'some_long' 'long ()' + // CHECK-NEXT: wait clause has devnum has queues tag + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'int' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'int (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'int ()' lvalue Function{{.*}} 'some_int' 'int ()' + // CHECK-NEXT: CallExpr{{.*}}'long' + // CHECK-NEXT: ImplicitCastExpr{{.*}}'long (*)()' <FunctionToPointerDecay> + // CHECK-NEXT: DeclRefExpr{{.*}}'long ()' lvalue Function{{.*}} 'some_long' 'long ()' + // CHECK-NEXT: ForStmt +} + +template<typename U> +void TemplUses(U u) { + // CHECK: FunctionTemplateDecl + // CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 0 U + // CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void (U)' + // CHECK-NEXT: ParmVarDecl{{.*}} referenced u 'U' + // CHECK-NEXT: CompoundStmt + +#pragma acc parallel loop wait + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}parallel loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ForStmt + +#pragma acc serial loop wait() + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}serial loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ForStmt + +#pragma acc kernels loop wait(U::value, u) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}kernels loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '<dependent type>' lvalue + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'U' + // CHECK-NEXT: DeclRefExpr{{.*}} 'U' lvalue ParmVar{{.*}} 'u' 'U' + // CHECK-NEXT: ForStmt + +#pragma acc parallel loop wait(queues: U::value, u) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}parallel loop + // CHECK-NEXT: wait clause has queues tag + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '<dependent type>' lvalue + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'U' + // CHECK-NEXT: DeclRefExpr{{.*}} 'U' lvalue ParmVar{{.*}} 'u' 'U' + // CHECK-NEXT: ForStmt + +#pragma acc serial loop wait(devnum:u:queues: U::value, u) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}serial loop + // CHECK-NEXT: wait clause has devnum has queues tag + // CHECK-NEXT: DeclRefExpr{{.*}} 'U' lvalue ParmVar{{.*}} 'u' 'U' + // CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '<dependent type>' lvalue + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'U' + // CHECK-NEXT: DeclRefExpr{{.*}} 'U' lvalue ParmVar{{.*}} 'u' 'U' + // CHECK-NEXT: ForStmt + +#pragma acc kernels loop wait(devnum:u: U::value, u) + for (int i = 0; i < 5; ++i) {} + // CHECK: OpenACCCombinedConstruct{{.*}}kernels loop + // CHECK-NEXT: wait clause has devnum + // CHECK-NEXT: DeclRefExpr{{.*}} 'U' lvalue ParmVar{{.*}} 'u' 'U' + // CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '<dependent type>' lvalue + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'U' + // CHECK-NEXT: DeclRefExpr{{.*}} 'U' lvalue ParmVar{{.*}} 'u' 'U' + // CHECK-NEXT: ForStmt + + // Check the instantiated versions of the above. + // CHECK: FunctionDecl{{.*}} used TemplUses 'void (HasInt)' implicit_instantiation + // CHECK-NEXT: TemplateArgument type 'HasInt' + // CHECK-NEXT: RecordType{{.*}} 'HasInt' + // CHECK-NEXT: CXXRecord{{.*}} 'HasInt' + // CHECK-NEXT: ParmVarDecl{{.*}} used u 'HasInt' + // CHECK-NEXT: CompoundStmt + + // CHECK: OpenACCCombinedConstruct{{.*}}parallel loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ForStmt + + // CHECK: OpenACCCombinedConstruct{{.*}}serial loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ForStmt + + // CHECK: OpenACCCombinedConstruct{{.*}}kernels loop + // CHECK-NEXT: wait clause + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> + // CHECK-NEXT: DeclRefExpr{{.*}} 'const int' lvalue Var{{.*}} 'value' 'const int' + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'HasInt' + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'char' <UserDefinedConversion> + // CHECK-NEXT: CXXMemberCallExpr{{.*}}'char' + // CHECK-NEXT: MemberExpr{{.*}} '<bound member function type>' .operator char + // CHECK-NEXT: DeclRefExpr{{.*}} 'HasInt' lvalue ParmVar + // CHECK-NEXT: ForStmt + + // CHECK: OpenACCCombinedConstruct{{.*}}parallel loop + // CHECK-NEXT: wait clause has queues tag + // CHECK-NEXT: <<<NULL>>> + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> + // CHECK-NEXT: DeclRefExpr{{.*}} 'const int' lvalue Var{{.*}} 'value' 'const int' + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'HasInt' + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'char' <UserDefinedConversion> + // CHECK-NEXT: CXXMemberCallExpr{{.*}}'char' + // CHECK-NEXT: MemberExpr{{.*}} '<bound member function type>' .operator char + // CHECK-NEXT: DeclRefExpr{{.*}} 'HasInt' lvalue ParmVar + // CHECK-NEXT: ForStmt + + // CHECK: OpenACCCombinedConstruct{{.*}}serial loop + // CHECK-NEXT: wait clause has devnum has queues tag + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'char' <UserDefinedConversion> + // CHECK-NEXT: CXXMemberCallExpr{{.*}}'char' + // CHECK-NEXT: MemberExpr{{.*}} '<bound member function type>' .operator char + // CHECK-NEXT: DeclRefExpr{{.*}} 'HasInt' lvalue ParmVar + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> + // CHECK-NEXT: DeclRefExpr{{.*}} 'const int' lvalue Var{{.*}} 'value' 'const int' + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'HasInt' + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'char' <UserDefinedConversion> + // CHECK-NEXT: CXXMemberCallExpr{{.*}}'char' + // CHECK-NEXT: MemberExpr{{.*}} '<bound member function type>' .operator char + // CHECK-NEXT: DeclRefExpr{{.*}} 'HasInt' lvalue ParmVar + // CHECK-NEXT: ForStmt + + // CHECK: OpenACCCombinedConstruct{{.*}}kernels loop + // CHECK-NEXT: wait clause has devnum + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'char' <UserDefinedConversion> + // CHECK-NEXT: CXXMemberCallExpr{{.*}}'char' + // CHECK-NEXT: MemberExpr{{.*}} '<bound member function type>' .operator char + // CHECK-NEXT: DeclRefExpr{{.*}} 'HasInt' lvalue ParmVar + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> + // CHECK-NEXT: DeclRefExpr{{.*}} 'const int' lvalue Var{{.*}} 'value' 'const int' + // CHECK-NEXT: NestedNameSpecifier TypeSpec 'HasInt' + // CHECK-NEXT: ImplicitCastExpr{{.*}} 'char' <UserDefinedConversion> + // CHECK-NEXT: CXXMemberCallExpr{{.*}}'char' + // CHECK-NEXT: MemberExpr{{.*}} '<bound member function type>' .operator char + // CHECK-NEXT: DeclRefExpr{{.*}} 'HasInt' lvalue ParmVar + // CHECK-NEXT: ForStmt +} + +struct HasInt { + using IntTy = int; + using ShortTy = short; + static constexpr int value = 1; + + operator char(); +}; + +void Inst() { + TemplUses<HasInt>({}); +} +#endif diff --git a/clang/test/SemaOpenACC/combined-construct-wait-clause.c b/clang/test/SemaOpenACC/combined-construct-wait-clause.c new file mode 100644 index 00000000000000..7551dd18409637 --- /dev/null +++ b/clang/test/SemaOpenACC/combined-construct-wait-clause.c @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 %s -fopenacc -verify + +struct NotConvertible{} NC; +short getS(); +int getI(); + +void uses() { + int arr[5]; + +#pragma acc parallel loop wait + for (unsigned i = 0; i < 5; ++i); + +#pragma acc serial loop wait() + for (unsigned i = 0; i < 5; ++i); + +#pragma acc kernels loop wait(getS(), getI()) + for (unsigned i = 0; i < 5; ++i); + +#pragma acc parallel loop wait(devnum:getS(): getI()) + for (unsigned i = 0; i < 5; ++i); + +#pragma acc parallel loop wait(devnum:getS(): queues: getI()) wait(devnum:getI(): queues: getS(), getI(), 5) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} +#pragma acc parallel loop wait(devnum:NC : 5) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} +#pragma acc parallel loop wait(devnum:5 : NC) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+3{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}} + // expected-error@+2{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}} + // expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}} +#pragma acc parallel loop wait(devnum:arr : queues: arr, NC, 5) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+1{{OpenACC 'wait' clause is not valid on 'loop' directive}} +#pragma acc loop wait + for(int i = 5; i < 10;++i); +} diff --git a/clang/test/SemaOpenACC/combined-construct-wait-clause.cpp b/clang/test/SemaOpenACC/combined-construct-wait-clause.cpp new file mode 100644 index 00000000000000..9ce04290cbe5a7 --- /dev/null +++ b/clang/test/SemaOpenACC/combined-construct-wait-clause.cpp @@ -0,0 +1,104 @@ +// RUN: %clang_cc1 %s -fopenacc -verify + +struct ExplicitConvertOnly { + explicit operator int() const; // #EXPL_CONV +} Explicit; + +struct AmbiguousConvert{ + operator int(); // #AMBIG_INT + operator short(); // #AMBIG_SHORT + operator float(); +} Ambiguous; + +void Test() { + + // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}} + // expected-note@#AMBIG_INT{{conversion to integral type 'int'}} + // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} +#pragma acc parallel loop wait(Ambiguous) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+2{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}} + // expected-note@#EXPL_CONV{{conversion to integral type 'int'}} +#pragma acc parallel loop wait(4, Explicit, 5) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}} + // expected-note@#AMBIG_INT{{conversion to integral type 'int'}} + // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} +#pragma acc parallel loop wait(queues: Ambiguous, 5) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+2{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}} + // expected-note@#EXPL_CONV{{conversion to integral type 'int'}} +#pragma acc parallel loop wait(devnum: Explicit: 5) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+2{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}} + // expected-note@#EXPL_CONV{{conversion to integral type 'int'}} +#pragma acc parallel loop wait(devnum: Explicit:queues: 5) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+1{{use of undeclared identifier 'queues'}} +#pragma acc parallel loop wait(devnum: queues: 5) + for (unsigned i = 0; i < 5; ++i); +} + +struct HasInt { + using IntTy = int; + using ShortTy = short; + static constexpr int value = 1; + static constexpr AmbiguousConvert ACValue; + static constexpr ExplicitConvertOnly EXValue; + + operator char(); +}; + +template<typename T> +void TestInst() { + +#pragma acc parallel loop wait(T{}) + for (unsigned i = 0; i < 5; ++i); + +#pragma acc parallel loop wait(devnum:typename T::ShortTy{}:queues:typename T::IntTy{}) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+4{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} + // expected-note@#INST{{in instantiation of function template specialization}} + // expected-note@#AMBIG_INT{{conversion to integral type 'int'}} + // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} +#pragma acc parallel loop wait(devnum:T::value :queues:T::ACValue) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+5{{OpenACC integer expression type 'const ExplicitConvertOnly' requires explicit conversion to 'int'}} + // expected-note@#EXPL_CONV{{conversion to integral type 'int'}} + // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} + // expected-note@#AMBIG_INT{{conversion to integral type 'int'}} + // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} +#pragma acc parallel loop wait(devnum:T::EXValue :queues:T::ACValue) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+5{{OpenACC integer expression type 'const ExplicitConvertOnly' requires explicit conversion to 'int'}} + // expected-note@#EXPL_CONV{{conversion to integral type 'int'}} + // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} + // expected-note@#AMBIG_INT{{conversion to integral type 'int'}} + // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} +#pragma acc parallel loop wait(T::EXValue, T::ACValue) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+5{{OpenACC integer expression type 'const ExplicitConvertOnly' requires explicit conversion to 'int'}} + // expected-note@#EXPL_CONV{{conversion to integral type 'int'}} + // expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}} + // expected-note@#AMBIG_INT{{conversion to integral type 'int'}} + // expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}} +#pragma acc parallel loop wait(queues: T::EXValue, T::ACValue) + for (unsigned i = 0; i < 5; ++i); + + // expected-error@+1{{no member named 'Invalid' in 'HasInt'}} +#pragma acc parallel loop wait(queues: T::Invalid, T::Invalid2) + for (unsigned i = 0; i < 5; ++i); +} + +void Inst() { + TestInst<HasInt>(); // #INST +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits