Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
In the expression evaluator, descend into both the true and false exp…
…ressions of a ConditionalOperator when the condition can't be evaluated and we're in an evaluation mode that says we should continue evaluating.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301520 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
nlewycky committed Apr 27, 2017
1 parent 6b7fb45 commit 74bc51f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/AST/ExprConstant.cpp
Expand Up @@ -4418,8 +4418,14 @@ class ExprEvaluatorBase
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;
}

Expand Down
3 changes: 3 additions & 0 deletions test/Sema/integer-overflow.c
Expand Up @@ -147,6 +147,9 @@ uint64_t check_integer_overflows(int i) {
uint64_t a[10];
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)));
}
Expand Down

0 comments on commit 74bc51f

Please sign in to comment.