diff options
-rw-r--r-- | lib/AST/Expr.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 3 | ||||
-rw-r--r-- | test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp | 21 | ||||
-rw-r--r-- | test/SemaCXX/PR5086-ambig-resolution-enum.cpp | 13 |
4 files changed, 15 insertions, 25 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index dcfd1474f1..7461e635c6 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1674,7 +1674,8 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx, return true; // This expression must be an integer type. - if (!getType()->isIntegerType()) + if (!getType()->isIntegerType() || + (Ctx.getLangOptions().CPlusPlus && getType()->isEnumeralType())) return false; // If we have an integer constant expression, we need to *evaluate* it and diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 433ca79b48..18614f7870 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -887,9 +887,6 @@ static bool isNullPointerConstantForConversion(Expr *Expr, Expr->getType()->isIntegralType()) return !InOverloadResolution; - if (Expr->getType()->isEnumeralType()) - return !InOverloadResolution; - return Expr->isNullPointerConstant(Context, InOverloadResolution? Expr::NPC_ValueDependentIsNotNull : Expr::NPC_ValueDependentIsNull); diff --git a/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp b/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp deleted file mode 100644 index 49bf7997b1..0000000000 --- a/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true - -class UnicodeString { -public: - enum EInvariant { kInvariant }; - int extract(int targetCapacity, enum EInvariant inv) const; - int extract(unsigned targetLength, const char *codepage) const; -}; - -void foo(const UnicodeString& id) { - enum {BUFLEN = 128 }; - id.extract(BUFLEN - 2, UnicodeString::kInvariant); -} - -// CHECK-LP64: call __ZNK13UnicodeString7extractEiNS_10EInvariantE - -// CHECK-LP32: call L__ZNK13UnicodeString7extractEiNS_10EInvariantE diff --git a/test/SemaCXX/PR5086-ambig-resolution-enum.cpp b/test/SemaCXX/PR5086-ambig-resolution-enum.cpp new file mode 100644 index 0000000000..838bc6f3c7 --- /dev/null +++ b/test/SemaCXX/PR5086-ambig-resolution-enum.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x + +class C { +public: + enum E { e1=0 }; + const char * fun1(int , enum E) const; + int fun1(unsigned, const char *) const; +}; + +void foo(const C& rc) { + enum {BUFLEN = 128 }; + const char *p = rc.fun1(BUFLEN - 2, C::e1); +} |