diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-14 21:38:30 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-14 21:38:30 +0000 |
commit | 98a0a49fbfdfc1933e1f40cce630d7f4bccf5afa (patch) | |
tree | d44a4d72832911062d3f734c7a4f558f0f68ca56 /clang/lib/AST/Expr.cpp | |
parent | 89dbd3ba40d1d945c2142c2d57f908bba038659f (diff) | |
download | bcm5719-llvm-98a0a49fbfdfc1933e1f40cce630d7f4bccf5afa.tar.gz bcm5719-llvm-98a0a49fbfdfc1933e1f40cce630d7f4bccf5afa.zip |
Pending clear answer from WG21 on whether core issue 903 is intended to apply to
C++11 or just C++17, restrict the set of null pointer constants in C++11 mode
back to those which were considered null in C++98.
llvm-svn: 150510
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 5d22d144f48..5b511cc8831 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2728,11 +2728,18 @@ Expr::isNullPointerConstant(ASTContext &Ctx, return NPCK_NotNull; // If we have an integer constant expression, we need to *evaluate* it and - // test for the value 0. - llvm::APSInt Result; - bool IsNull = isIntegerConstantExpr(Result, Ctx) && Result == 0; + // test for the value 0. Don't use the C++11 constant expression semantics + // for this, for now; once the dust settles on core issue 903, we might only + // allow a literal 0 here in C++11 mode. + if (Ctx.getLangOptions().CPlusPlus0x) { + if (!isCXX98IntegralConstantExpr(Ctx)) + return NPCK_NotNull; + } else { + if (!isIntegerConstantExpr(Ctx)) + return NPCK_NotNull; + } - return (IsNull ? NPCK_ZeroInteger : NPCK_NotNull); + return (EvaluateKnownConstInt(Ctx) == 0) ? NPCK_ZeroInteger : NPCK_NotNull; } /// \brief If this expression is an l-value for an Objective C |