From: Alexey Bataev Date: Tue, 19 May 2015 08:19:24 +0000 (+0000) Subject: [OPENMP] Prohibit variably modified types in 'copyprivate' clause. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b777f2409f70c779162dee0442f087920d518a4a;p=clang [OPENMP] Prohibit variably modified types in 'copyprivate' clause. Runtime does not allow to work with VLAs in copyprivate clause. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237672 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 2f41921578..91575b8b36 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -7418,6 +7418,8 @@ def err_omp_no_dsa_for_variable : Error< "variable %0 must have explicitly specified data sharing attributes">; 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">; 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 9d45f8213c..e34fb2bc7d 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -6195,6 +6195,17 @@ 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; + bool IsDecl = + VD->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly; + Diag(VD->getLocation(), + IsDecl ? diag::note_previous_decl : diag::note_defined_here) + << 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 cb31f0cd10..a2ffdef033 100644 --- a/test/OpenMP/single_copyprivate_messages.cpp +++ b/test/OpenMP/single_copyprivate_messages.cpp @@ -105,8 +105,8 @@ T tmain(T argc, C **argv) { return T(); } -void bar(S4 a[2]) { -#pragma omp single copyprivate(a) // expected-error {{'operator=' is a private member of 'S4'}} +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]'}} foo(); }