From: Alexey Bataev Date: Tue, 19 May 2015 08:44:56 +0000 (+0000) Subject: [OPENMP] Prohibit VLAs in 'private/firstprivate' clauses of 'task' directive. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34c2a4c1e074abedcb681e44858720eb27b33e3d;p=clang [OPENMP] Prohibit VLAs in 'private/firstprivate' clauses of 'task' directive. Currently runtime does not allow to support variably modified types for 'private' and 'firstprivate' clauses in 'task' directives. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237674 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 91575b8b36..9ccd5adf21 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -7419,7 +7419,7 @@ def err_omp_no_dsa_for_variable : Error< def err_omp_wrong_dsa : Error< "%0 variable cannot be %1">; def err_omp_variably_modified_type_not_supported : Error< - "arguments of OpenMP clause '%0' cannot be of variably-modified type %1">; + "arguments of OpenMP clause '%0' in '#pragma omp %2' directive cannot be of variably-modified type %1">; def note_omp_explicit_dsa : Note< "defined as %0">; def note_omp_predetermined_dsa : Note< diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index e34fb2bc7d..126d6fa60f 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -4803,6 +4803,20 @@ OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef VarList, continue; } + // Variably modified types are not supported for tasks. + if (Type->isVariablyModifiedType() && + DSAStack->getCurrentDirective() == OMPD_task) { + Diag(ELoc, diag::err_omp_variably_modified_type_not_supported) + << getOpenMPClauseName(OMPC_private) << Type + << getOpenMPDirectiveName(DSAStack->getCurrentDirective()); + bool IsDecl = + VD->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly; + Diag(VD->getLocation(), + IsDecl ? diag::note_previous_decl : diag::note_defined_here) + << VD; + continue; + } + // OpenMP [2.9.3.3, Restrictions, C/C++, p.1] // A variable of class type (or array thereof) that appears in a private // clause requires an accessible, unambiguous default constructor for the @@ -5020,6 +5034,20 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef VarList, } } + // Variably modified types are not supported for tasks. + if (Type->isVariablyModifiedType() && + DSAStack->getCurrentDirective() == OMPD_task) { + Diag(ELoc, diag::err_omp_variably_modified_type_not_supported) + << getOpenMPClauseName(OMPC_firstprivate) << Type + << getOpenMPDirectiveName(DSAStack->getCurrentDirective()); + bool IsDecl = + VD->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly; + Diag(VD->getLocation(), + IsDecl ? diag::note_previous_decl : diag::note_defined_here) + << VD; + continue; + } + Type = Type.getUnqualifiedType(); auto VDPrivate = buildVarDecl(*this, ELoc, Type, VD->getName()); // Generate helper private variable and initialize it with the value of the @@ -6198,7 +6226,8 @@ OMPClause *Sema::ActOnOpenMPCopyprivateClause(ArrayRef VarList, // Variably modified types are not supported. if (Type->isVariablyModifiedType()) { Diag(ELoc, diag::err_omp_variably_modified_type_not_supported) - << getOpenMPClauseName(OMPC_copyprivate) << Type; + << getOpenMPClauseName(OMPC_copyprivate) << Type + << getOpenMPDirectiveName(DSAStack->getCurrentDirective()); bool IsDecl = VD->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly; Diag(VD->getLocation(), @@ -6206,6 +6235,7 @@ OMPClause *Sema::ActOnOpenMPCopyprivateClause(ArrayRef VarList, << VD; continue; } + // OpenMP [2.14.4.1, Restrictions, C/C++, p.2] // A variable of class type (or array thereof) that appears in a // copyin clause requires an accessible, unambiguous copy assignment diff --git a/test/OpenMP/single_copyprivate_messages.cpp b/test/OpenMP/single_copyprivate_messages.cpp index a2ffdef033..f941c8e9b3 100644 --- a/test/OpenMP/single_copyprivate_messages.cpp +++ b/test/OpenMP/single_copyprivate_messages.cpp @@ -106,7 +106,7 @@ T tmain(T argc, C **argv) { } void bar(S4 a[2], int n, int b[n]) { // expected-note {{'b' defined here}} -#pragma omp single copyprivate(a, b) // expected-error {{'operator=' is a private member of 'S4'}} expected-error {{arguments of OpenMP clause 'copyprivate' cannot be of variably-modified type 'int [n]'}} +#pragma omp single copyprivate(a, b) // expected-error {{'operator=' is a private member of 'S4'}} expected-error {{arguments of OpenMP clause 'copyprivate' in '#pragma omp single' directive cannot be of variably-modified type 'int [n]'}} foo(); } diff --git a/test/OpenMP/task_firstprivate_messages.cpp b/test/OpenMP/task_firstprivate_messages.cpp index c3c2ae053e..4eba5b25fa 100644 --- a/test/OpenMP/task_firstprivate_messages.cpp +++ b/test/OpenMP/task_firstprivate_messages.cpp @@ -51,6 +51,11 @@ public: S3 h; #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} +void bar(int n, int b[n]) { // expected-note {{'b' defined here}} +#pragma omp task firstprivate(b) // expected-error {{arguments of OpenMP clause 'firstprivate' in '#pragma omp task' directive cannot be of variably-modified type 'int [n]'}} + foo(); +} + namespace A { double x; #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} diff --git a/test/OpenMP/task_private_messages.cpp b/test/OpenMP/task_private_messages.cpp index bf2a24a4a0..59a4e61908 100644 --- a/test/OpenMP/task_private_messages.cpp +++ b/test/OpenMP/task_private_messages.cpp @@ -45,6 +45,11 @@ public: int threadvar; #pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}} +void bar(int n, int b[n]) { // expected-note {{'b' defined here}} +#pragma omp task private(b) // expected-error {{arguments of OpenMP clause 'private' in '#pragma omp task' directive cannot be of variably-modified type 'int [n]'}} + foo(); +} + namespace A { double x; #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}