[cfe-commits] r83217 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp

Fariborz Jahanian fjahanian at apple.com
Thu Oct 1 15:10:15 PDT 2009


Author: fjahanian
Date: Thu Oct  1 17:10:15 2009
New Revision: 83217

URL: http://llvm.org/viewvc/llvm-project?rev=83217&view=rev
Log:
enumerator value of 0 is not a null pointer constant for
deciding const of null pointer conversion. Fixes PR5086.

Added:
    cfe/trunk/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=83217&r1=83216&r2=83217&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Oct  1 17:10:15 2009
@@ -887,6 +887,9 @@
       Expr->getType()->isIntegralType())
     return !InOverloadResolution;
 
+  if (Expr->getType()->isEnumeralType())
+    return !InOverloadResolution;
+
   return Expr->isNullPointerConstant(Context,
                     InOverloadResolution? Expr::NPC_ValueDependentIsNotNull
                                         : Expr::NPC_ValueDependentIsNull);

Added: cfe/trunk/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp?rev=83217&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp Thu Oct  1 17:10:15 2009
@@ -0,0 +1,21 @@
+// 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





More information about the cfe-commits mailing list