summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2017-04-27 07:11:09 +0000
committerNick Lewycky <nicholas@mxc.ca>2017-04-27 07:11:09 +0000
commit20edee6a3e4f077da25360edebb8180afebb03ed (patch)
tree0a12cd32e0f344745c095db07cf5069732d4924c
parent0f8f177682ddd91e7fe84595170d8e4986516e3b (diff)
downloadbcm5719-llvm-20edee6a3e4f077da25360edebb8180afebb03ed.tar.gz
bcm5719-llvm-20edee6a3e4f077da25360edebb8180afebb03ed.zip
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.
llvm-svn: 301520
-rw-r--r--clang/lib/AST/ExprConstant.cpp8
-rw-r--r--clang/test/Sema/integer-overflow.c3
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 2fafa487675..5c5b3daf70c 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -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;
}
diff --git a/clang/test/Sema/integer-overflow.c b/clang/test/Sema/integer-overflow.c
index e74bc119798..12d2c4f29e0 100644
--- a/clang/test/Sema/integer-overflow.c
+++ b/clang/test/Sema/integer-overflow.c
@@ -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)));
}
OpenPOWER on IntegriCloud