]> granicus.if.org Git - clang/commitdiff
Change isNullPointerConstant to be strict; hopefully this won't cause
authorEli Friedman <eli.friedman@gmail.com>
Sat, 25 Apr 2009 22:37:12 +0000 (22:37 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 25 Apr 2009 22:37:12 +0000 (22:37 +0000)
any issues now that we have our own tgmath.h.

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

lib/AST/Expr.cpp
test/Sema/i-c-e.c

index 970d29519214d90e3797d8c36c22f8726952cd38..f9ca323a4747059a2ab7c2f0acffc50967124785 100644 (file)
@@ -1374,12 +1374,8 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const
   
   // If we have an integer constant expression, we need to *evaluate* it and
   // test for the value 0.
-  // FIXME: We should probably return false if we're compiling in strict mode
-  // and Diag is not null (this indicates that the value was foldable but not
-  // an ICE.
-  EvalResult Result;
-  return Evaluate(Result, Ctx) && !Result.HasSideEffects &&
-        Result.Val.isInt() && Result.Val.getInt() == 0;
+  llvm::APSInt Result;
+  return isIntegerConstantExpr(Result, Ctx) && Result == 0;
 }
 
 /// isBitField - Return true if this expression is a bit-field.
index 6bc354139950707804e64ea7ce2170611a8b3b20..6afe035e1cf312b1e08a2306cda6e804ae759481 100644 (file)
@@ -3,7 +3,7 @@
 #include <stdint.h>
 #include <limits.h>
 
-int a() {int p; *(1 ? &p : (void*)(0 && (a(),1))) = 10;}
+int a() {int p; *(1 ? &p : (void*)(0 && (a(),1))) = 10;} // expected-error {{incomplete type 'void' is not assignable}}
 
 // rdar://6091492 - ?: with __builtin_constant_p as the operand is an i-c-e.
 int expr;