]> granicus.if.org Git - clang/commitdiff
Fix PR21945: Crash in constant evaluator.
authorJonathan Roelofs <jonathan@codesourcery.com>
Mon, 1 Jun 2015 16:23:08 +0000 (16:23 +0000)
committerJonathan Roelofs <jonathan@codesourcery.com>
Mon, 1 Jun 2015 16:23:08 +0000 (16:23 +0000)
Patch by Косов Евгений!

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

lib/AST/ExprConstant.cpp
test/Sema/const-eval.c

index d1ec7aea1d2a8b73ee595a9683129801b3074808..be24a2ae2c8c9aaa86d04cc0d7ce0c976d9816c2 100644 (file)
@@ -4276,6 +4276,9 @@ public:
 
     BlockScopeRAII Scope(Info);
     const CompoundStmt *CS = E->getSubStmt();
+    if (CS->body_empty())
+      return true;
+
     for (CompoundStmt::const_body_iterator BI = CS->body_begin(),
                                            BE = CS->body_end();
          /**/; ++BI) {
@@ -4301,6 +4304,8 @@ public:
         return false;
       }
     }
+
+    llvm_unreachable("Return from function from the loop above.");
   }
 
   /// Visit a value which is evaluated, but whose value is ignored.
index 883cced9f3b078f29e23e0f484ce9d9046e9b307..5f5b6f3dc198165d3c6dd179e7c66c481d78e222 100644 (file)
@@ -134,3 +134,6 @@ EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-e
 
 // <rdar://problem/11874571>
 EVAL_EXPR(51, 0 != (float)1e99)
+
+// PR21945
+void PR21945() { int i = (({}), 0l); }