]> granicus.if.org Git - clang/commitdiff
enumerator value of 0 is not a null pointer constant for
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 1 Oct 2009 22:10:15 +0000 (22:10 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 1 Oct 2009 22:10:15 +0000 (22:10 +0000)
deciding const of null pointer conversion. Fixes PR5086.

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

lib/Sema/SemaOverload.cpp
test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp [new file with mode: 0644]

index 18614f78709666cac0fe8d945fd8e00fb853c0b6..433ca79b48f0fdc8d87246caae74aa1c4f5ccccb 100644 (file)
@@ -887,6 +887,9 @@ 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
new file mode 100644 (file)
index 0000000..49bf799
--- /dev/null
@@ -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