From: Jonathan Roelofs Date: Mon, 1 Jun 2015 16:23:08 +0000 (+0000) Subject: Fix PR21945: Crash in constant evaluator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93a42cb8d73d6b0cf343761313eb9de8620db99a;p=clang Fix PR21945: Crash in constant evaluator. Patch by Косов Евгений! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238758 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index d1ec7aea1d..be24a2ae2c 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -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. diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index 883cced9f3..5f5b6f3dc1 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -134,3 +134,6 @@ EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-e // EVAL_EXPR(51, 0 != (float)1e99) + +// PR21945 +void PR21945() { int i = (({}), 0l); }