From a216d92e798d88a5eb0e8d31d2f45f1a2420f762 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 5 Aug 2015 18:38:07 +0000 Subject: [PATCH] Merging r243964: ------------------------------------------------------------------------ r243964 | abataev | 2015-08-04 01:10:48 -0700 (Tue, 04 Aug 2015) | 4 lines [OPENMP] Fix compiler crash during data-sharing attributes analysis. If a global variable is marked as private in OpenMP construct and then is used in of the private clauses of the same construct, it might cause compiler crash because of incorrect capturing. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_37@244090 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOpenMP.cpp | 4 +++- test/OpenMP/simd_linear_messages.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 77e120bd60..644b340da1 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -657,7 +657,9 @@ void Sema::InitDataSharingAttributesStack() { bool Sema::IsOpenMPCapturedVar(VarDecl *VD) { assert(LangOpts.OpenMP && "OpenMP is not allowed"); VD = VD->getCanonicalDecl(); - if (DSAStack->getCurrentDirective() != OMPD_unknown) { + if (DSAStack->getCurrentDirective() != OMPD_unknown && + (!DSAStack->isClauseParsingMode() || + DSAStack->getParentDirective() != OMPD_unknown)) { if (DSAStack->isLoopControlVariable(VD) || (VD->hasLocalStorage() && isParallelOrTaskRegion(DSAStack->getCurrentDirective())) || diff --git a/test/OpenMP/simd_linear_messages.cpp b/test/OpenMP/simd_linear_messages.cpp index 78f905fd94..6fac26290b 100644 --- a/test/OpenMP/simd_linear_messages.cpp +++ b/test/OpenMP/simd_linear_messages.cpp @@ -156,6 +156,7 @@ namespace C { using A::x; } +int f; int main(int argc, char **argv) { double darr[100]; // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} @@ -167,6 +168,8 @@ int main(int argc, char **argv) { S5 g(5); // expected-note {{'g' defined here}} int i; int &j = i; // expected-note {{'j' defined here}} + #pragma omp simd linear(f) linear(f) // expected-error {{linear variable cannot be linear}} expected-note {{defined as linear}} + for (int k = 0; k < argc; ++k) ++k; #pragma omp simd linear // expected-error {{expected '(' after 'linear'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} -- 2.50.1