Author: nicholas Date: Thu Apr 27 02:11:09 2017 New Revision: 301520 URL: http://llvm.org/viewvc/llvm-project?rev=301520&view=rev Log: In the expression evaluator, descend into both the true and false expressions of a ConditionalOperator when the condition can't be evaluated and we're in an evaluation mode that says we should continue evaluating.
Modified: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/test/Sema/integer-overflow.c Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=301520&r1=301519&r2=301520&view=diff ============================================================================== --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr 27 02:11:09 2017 @@ -4418,8 +4418,14 @@ private: bool HandleConditionalOperator(const ConditionalOperator *E) { bool BoolResult; if (!EvaluateAsBooleanCondition(E->getCond(), BoolResult, Info)) { - if (Info.checkingPotentialConstantExpression() && Info.noteFailure()) + if (Info.checkingPotentialConstantExpression() && Info.noteFailure()) { CheckPotentialConstantConditional(E); + return false; + } + if (Info.noteFailure()) { + StmtVisitorTy::Visit(E->getTrueExpr()); + StmtVisitorTy::Visit(E->getFalseExpr()); + } return false; } Modified: cfe/trunk/test/Sema/integer-overflow.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/integer-overflow.c?rev=301520&r1=301519&r2=301520&view=diff ============================================================================== --- cfe/trunk/test/Sema/integer-overflow.c (original) +++ cfe/trunk/test/Sema/integer-overflow.c Thu Apr 27 02:11:09 2017 @@ -148,6 +148,9 @@ uint64_t check_integer_overflows(int i) a[4608 * 1024 * 1024] = 1i; // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} + (void)((i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024)) + 1); + +// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits