]> granicus.if.org Git - clang/commitdiff
[OPENMP] Prohibit VLAs in 'private/firstprivate' clauses of 'task' directive.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 19 May 2015 08:44:56 +0000 (08:44 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 19 May 2015 08:44:56 +0000 (08:44 +0000)
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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaOpenMP.cpp
test/OpenMP/single_copyprivate_messages.cpp
test/OpenMP/task_firstprivate_messages.cpp
test/OpenMP/task_private_messages.cpp

index 91575b8b3674c40a541075a56bbec006504505c1..9ccd5adf21abb94587789209ada99aa7dbd2e9e8 100644 (file)
@@ -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<
index e34fb2bc7d6682894f89caf5c3a5771a21d511b2..126d6fa60f8008de904c84537b80fbbd7b8eb160 100644 (file)
@@ -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
index a2ffdef033d5406a8b12c694437ecc83e2a501e3..f941c8e9b36139762f2a933b8f2680e2d3475434 100644 (file)
@@ -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();
 }
 
index c3c2ae053eee7fbd358f54be8a2c89c65c3b672b..4eba5b25fa9d36a1a1c1efcd5af5d20411f91876 100644 (file)
@@ -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}}
index bf2a24a4a0c828316a454f1eedb4535e41bfffa9..59a4e61908d93e4ff16f574399e297c0ac44d1c3 100644 (file)
@@ -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}}