diff options
-rw-r--r-- | lib/AST/ExprConstant.cpp | 7 | ||||
-rw-r--r-- | test/CodeGen/exprs.c | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index bedc78c0c0..0ffbf581a2 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -517,16 +517,17 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { // Evaluate the side that actually matters; this needs to be // handled specially because calling Visit() on the LHS can // have strange results when it doesn't have an integral type. - Visit(E->getRHS()); + if (Visit(E->getRHS())) + return true; // Check for isEvaluated; the idea is that this might eventually // be useful for isICE and other similar uses that care about // whether a comma is evaluated. This isn't really used yet, though, // and I'm not sure it really works as intended. if (!Info.isEvaluated) - return true; + return Extension(E->getOperatorLoc(), diag::ext_comma_in_constant_expr); - return Extension(E->getOperatorLoc(), diag::ext_comma_in_constant_expr); + return false; } if (E->isLogicalOp()) { diff --git a/test/CodeGen/exprs.c b/test/CodeGen/exprs.c index f1c9a5d73f..275c988ab9 100644 --- a/test/CodeGen/exprs.c +++ b/test/CodeGen/exprs.c @@ -39,3 +39,9 @@ int test5(const float x, float float_number) { return __builtin_isless(x, float_number); } +// this one shouldn't fold +int ola() { + int a=2; + if ((0, (int)a) & 2) { return 1; } + return 2; +} |