]> granicus.if.org Git - clang/commitdiff
In the expression evaluator, descend into both the true and false expressions of...
authorNick Lewycky <nicholas@mxc.ca>
Thu, 27 Apr 2017 07:11:09 +0000 (07:11 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 27 Apr 2017 07:11:09 +0000 (07:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301520 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/Sema/integer-overflow.c

index 2fafa48767584e852f76f36c03088a6b19973ea0..5c5b3daf70cc712d536c7ce8692ac3462bdba910 100644 (file)
@@ -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;
     }
 
index e74bc119798b86926d68cbc45c8c916d3fcdb65f..12d2c4f29e0562bbdb928746c5490958aff1d1d7 100644 (file)
@@ -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)));
 }