summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp32
-rw-r--r--clang/test/OpenMP/single_copyprivate_messages.cpp2
-rw-r--r--clang/test/OpenMP/task_firstprivate_messages.cpp5
-rw-r--r--clang/test/OpenMP/task_private_messages.cpp5
5 files changed, 43 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 91575b8b367..9ccd5adf21a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/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/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index e34fb2bc7d6..126d6fa60f8 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4803,6 +4803,20 @@ OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef<Expr *> 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<Expr *> 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<Expr *> 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<Expr *> 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/clang/test/OpenMP/single_copyprivate_messages.cpp b/clang/test/OpenMP/single_copyprivate_messages.cpp
index a2ffdef033d..f941c8e9b36 100644
--- a/clang/test/OpenMP/single_copyprivate_messages.cpp
+++ b/clang/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/clang/test/OpenMP/task_firstprivate_messages.cpp b/clang/test/OpenMP/task_firstprivate_messages.cpp
index c3c2ae053ee..4eba5b25fa9 100644
--- a/clang/test/OpenMP/task_firstprivate_messages.cpp
+++ b/clang/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/clang/test/OpenMP/task_private_messages.cpp b/clang/test/OpenMP/task_private_messages.cpp
index bf2a24a4a0c..59a4e61908d 100644
--- a/clang/test/OpenMP/task_private_messages.cpp
+++ b/clang/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}}
OpenPOWER on IntegriCloud