r243964 - [OPENMP] Fix compiler crash during data-sharing attributes analysis.

Alexey Bataev a.bataev at hotmail.com
Tue Aug 4 01:10:49 PDT 2015


Author: abataev
Date: Tue Aug  4 03:10:48 2015
New Revision: 243964

URL: http://llvm.org/viewvc/llvm-project?rev=243964&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Sema/SemaOpenMP.cpp
    cfe/trunk/test/OpenMP/simd_linear_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=243964&r1=243963&r2=243964&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Aug  4 03:10:48 2015
@@ -657,7 +657,9 @@ void Sema::InitDataSharingAttributesStac
 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())) ||

Modified: cfe/trunk/test/OpenMP/simd_linear_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_linear_messages.cpp?rev=243964&r1=243963&r2=243964&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/simd_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_linear_messages.cpp Tue Aug  4 03:10:48 2015
@@ -156,6 +156,7 @@ namespace C {
 using A::x;
 }
 
+int f;
 int main(int argc, char **argv) {
   double darr[100];
   // expected-note at +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 '('}}





More information about the cfe-commits mailing list