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

Fariborz Jahanian fjahanian at apple.com
Mon Oct 5 17:09:31 PDT 2009


Author: fjahanian
Date: Mon Oct  5 19:09:31 2009
New Revision: 83350

URL: http://llvm.org/viewvc/llvm-project?rev=83350&view=rev
Log:
Refixed pr5086 by letting Expr::isNullPointerConstant
handle checking for a null pointer for a zero-valued
enumerator; moving the test case from CodeGen to Sema.

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

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=83350&r1=83349&r2=83350&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Oct  5 19:09:31 2009
@@ -1674,7 +1674,8 @@
     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

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Oct  5 19:09:31 2009
@@ -887,9 +887,6 @@
       Expr->getType()->isIntegralType())
     return !InOverloadResolution;
 
-  if (Expr->getType()->isEnumeralType())
-    return !InOverloadResolution;
-
   return Expr->isNullPointerConstant(Context,
                     InOverloadResolution? Expr::NPC_ValueDependentIsNotNull
                                         : Expr::NPC_ValueDependentIsNull);

Removed: 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=83349&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR5086-ambig-resolution-enum.cpp (removed)
@@ -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

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

==============================================================================
--- cfe/trunk/test/SemaCXX/PR5086-ambig-resolution-enum.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR5086-ambig-resolution-enum.cpp Mon Oct  5 19:09:31 2009
@@ -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);
+}





More information about the cfe-commits mailing list