]> granicus.if.org Git - clang/commitdiff
fix folding of comma if given a non-constant operand.
authorNuno Lopes <nunoplopes@sapo.pt>
Sun, 16 Nov 2008 20:09:07 +0000 (20:09 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Sun, 16 Nov 2008 20:09:07 +0000 (20:09 +0000)
Eli please take a look, as I'm not sure if this gets the extension warning in the right place

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59422 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/CodeGen/exprs.c

index bedc78c0c05d52895e709c53b9ae7a4a5a2d9adb..0ffbf581a2c1901824b02a4a5a8ee6da52f58098 100644 (file)
@@ -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()) {
index f1c9a5d73fa635566d8180efb7a46897f2c63343..275c988ab9bdda694b126131bf5dda577183c64e 100644 (file)
@@ -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;
+}