Author: abataev Date: Mon Apr 1 09:56:59 2019 New Revision: 357412 URL: http://llvm.org/viewvc/llvm-project?rev=357412&view=rev Log: [OPENMP]Allocate clause allocator in target region.
According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, allocate clauses that appear on a target construct or on constructs in a target region must specify an allocator expression unless a requires directive with the dynamic_allocators clause is present in the same compilation unit. Patch adds a check for this restriction. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/nvptx_allocate_messages.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=357412&r1=357411&r2=357412&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 1 09:56:59 2019 @@ -9158,6 +9158,9 @@ def note_omp_previous_allocator : Note< def err_expected_allocator_clause : Error<"expected an 'allocator' clause " "inside of the target region; provide an 'allocator' clause or use 'requires'" " directive with the 'dynamic_allocators' clause">; +def err_expected_allocator_expression : Error<"expected an allocator expression " + "inside of the target region; provide an allocator expression or use 'requires'" + " directive with the 'dynamic_allocators' clause">; def warn_omp_allocate_thread_on_task_target_directive : Warning< "allocator with the 'thread' trait access has unspecified behavior on '%0' directive">, InGroup<OpenMPClauses>; Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=357412&r1=357411&r2=357412&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Apr 1 09:56:59 2019 @@ -14852,6 +14852,15 @@ OMPClause *Sema::ActOnOpenMPAllocateClau if (AllocatorRes.isInvalid()) return nullptr; Allocator = AllocatorRes.get(); + } else { + // OpenMP 5.0, 2.11.4 allocate Clause, Restrictions. + // allocate clauses that appear on a target construct or on constructs in a + // target region must specify an allocator expression unless a requires + // directive with the dynamic_allocators clause is present in the same + // compilation unit. + if (LangOpts.OpenMPIsDevice && + !DSAStack->hasRequiresDeclWithClause<OMPDynamicAllocatorsClause>()) + targetDiag(StartLoc, diag::err_expected_allocator_expression); } // Analyze and build list of variables. SmallVector<Expr *, 8> Vars; Modified: cfe/trunk/test/OpenMP/nvptx_allocate_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_allocate_messages.cpp?rev=357412&r1=357411&r2=357412&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/nvptx_allocate_messages.cpp (original) +++ cfe/trunk/test/OpenMP/nvptx_allocate_messages.cpp Mon Apr 1 09:56:59 2019 @@ -57,6 +57,11 @@ template <class T> T foo() { T v; #pragma omp allocate(v) allocator(omp_cgroup_mem_alloc) v = ST<T>::m; +#if defined(DEVICE) && !defined(REQUIRES) +// expected-error@+2 2 {{expected an allocator expression inside of the target region; provide an allocator expression or use 'requires' directive with the 'dynamic_allocators' clause}} +#endif // DEVICE && !REQUIRES +#pragma omp parallel private(v) allocate(v) + v = 0; return v; } @@ -75,6 +80,7 @@ int main () { #endif // DEVICE && !REQUIRES #pragma omp allocate(b) #if defined(DEVICE) && !defined(REQUIRES) +// expected-note@+3 {{in instantiation of function template specialization 'foo<int>' requested here}} // expected-note@+2 {{called by 'main'}} #endif // DEVICE && !REQUIRES return (foo<int>() + bar()); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits