[cfe-commits] r59422 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/CodeGen/exprs.c

Nuno Lopes nunoplopes at sapo.pt
Sun Nov 16 12:09:08 PST 2008


Author: nlopes
Date: Sun Nov 16 14:09:07 2008
New Revision: 59422

URL: http://llvm.org/viewvc/llvm-project?rev=59422&view=rev
Log:
fix folding of comma if given a non-constant operand.
Eli please take a look, as I'm not sure if this gets the extension warning in the right place

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/CodeGen/exprs.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=59422&r1=59421&r2=59422&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Nov 16 14:09:07 2008
@@ -517,16 +517,17 @@
     // 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()) {

Modified: cfe/trunk/test/CodeGen/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exprs.c?rev=59422&r1=59421&r2=59422&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/exprs.c (original)
+++ cfe/trunk/test/CodeGen/exprs.c Sun Nov 16 14:09:07 2008
@@ -39,3 +39,9 @@
   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;
+}





More information about the cfe-commits mailing list