diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-11-12 02:22:34 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-11-12 02:22:34 +0000 |
commit | a5eef14ebaa1eb94ab0ba30d2ea72cbeeee81616 (patch) | |
tree | 312292084dc88c9797d0381dbb3228ed94f8146d /clang/lib/AST/Expr.cpp | |
parent | 0bc443b5c8102b87b9ba7c766beb90431228f716 (diff) | |
download | bcm5719-llvm-a5eef14ebaa1eb94ab0ba30d2ea72cbeeee81616.tar.gz bcm5719-llvm-a5eef14ebaa1eb94ab0ba30d2ea72cbeeee81616.zip |
-fms-compatibility: Use C++98 null pointer constant rules
Patch by Will Wilson!
llvm-svn: 194441
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index e467883288b..8bbf2ff5464 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3051,7 +3051,8 @@ bool Expr::hasNonTrivialCall(ASTContext &Ctx) { Expr::NullPointerConstantKind Expr::isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const { - if (isValueDependent() && !Ctx.getLangOpts().CPlusPlus11) { + if (isValueDependent() && + (!Ctx.getLangOpts().CPlusPlus11 || Ctx.getLangOpts().MicrosoftMode)) { switch (NPC) { case NPC_NeverValueDependent: llvm_unreachable("Unexpected value dependent expression!"); @@ -3133,8 +3134,13 @@ Expr::isNullPointerConstant(ASTContext &Ctx, if (Ctx.getLangOpts().CPlusPlus11) { // C++11 [conv.ptr]p1: A null pointer constant is an integer literal with // value zero or a prvalue of type std::nullptr_t. + // Microsoft mode permits C++98 rules reflecting MSVC behavior. const IntegerLiteral *Lit = dyn_cast<IntegerLiteral>(this); - return (Lit && !Lit->getValue()) ? NPCK_ZeroLiteral : NPCK_NotNull; + if (Lit && !Lit->getValue()) + return NPCK_ZeroLiteral; + else if (!Ctx.getLangOpts().MicrosoftMode || + !isCXX98IntegralConstantExpr(Ctx)) + return NPCK_NotNull; } else { // If we have an integer constant expression, we need to *evaluate* it and // test for the value 0. |