]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fix crash on loop control vars explicitly marked as private.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 28 Apr 2015 13:20:05 +0000 (13:20 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 28 Apr 2015 13:20:05 +0000 (13:20 +0000)
It is allowed to mark loop control vars as private in 'private' or 'lastprivate' clause, so no need to assert here.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235985 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmtOpenMP.cpp
test/OpenMP/for_private_codegen.cpp

index e445e7668ee493dfe0003e4dd00320eb58ec1090..6a4b5ecaa36fdc2e0570db6b95ecad6b579f9912 100644 (file)
@@ -578,15 +578,12 @@ static void EmitPrivateLoopCounters(CodeGenFunction &CGF,
                                     ArrayRef<Expr *> Counters) {
   for (auto *E : Counters) {
     auto VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
-    bool IsRegistered = LoopScope.addPrivate(VD, [&]() -> llvm::Value * {
+    (void)LoopScope.addPrivate(VD, [&]() -> llvm::Value *{
       // Emit var without initialization.
       auto VarEmission = CGF.EmitAutoVarAlloca(*VD);
       CGF.EmitAutoVarCleanups(VarEmission);
       return VarEmission.getAllocatedAddress();
     });
-    assert(IsRegistered && "counter already registered as private");
-    // Silence the warning about unused variable.
-    (void)IsRegistered;
   }
 }
 
index e87473bf39a54520332b9bd619b1ba6260cd1d99..f4d18340c81d8aefd220ce62ba37cbeefd80b354 100644 (file)
@@ -115,6 +115,12 @@ int main() {
     vec[i] = t_var;
     s_arr[i] = var;
   }
+  int i;
+#pragma omp parallel
+#pragma omp for private(i)
+  for (i = 0; i < 2; ++i) {
+    ;
+  }
   return tmain<int>();
 #endif
 }