[cfe-commits] r118269 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/nullptr.cpp

Anders Carlsson andersca at mac.com
Thu Nov 4 17:12:09 PDT 2010


Author: andersca
Date: Thu Nov  4 19:12:09 2010
New Revision: 118269

URL: http://llvm.org/viewvc/llvm-project?rev=118269&view=rev
Log:
Implement [over.ics.rank]p4: A conversion that does not convert an std::nullptr_t to bool is better than one than does.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/nullptr.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=118269&r1=118268&r2=118269&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov  4 19:12:09 2010
@@ -190,6 +190,7 @@
       (getFromType()->isPointerType() ||
        getFromType()->isObjCObjectPointerType() ||
        getFromType()->isBlockPointerType() ||
+       getFromType()->isNullPtrType() ||
        First == ICK_Array_To_Pointer || First == ICK_Function_To_Pointer))
     return true;
 

Modified: cfe/trunk/test/SemaCXX/nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nullptr.cpp?rev=118269&r1=118268&r2=118269&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/nullptr.cpp (original)
+++ cfe/trunk/test/SemaCXX/nullptr.cpp Thu Nov  4 19:12:09 2010
@@ -1,8 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -ffreestanding %s
 #include <stdint.h>
 
-// Don't have decltype yet.
-typedef __typeof__(nullptr) nullptr_t;
+typedef decltype(nullptr) nullptr_t;
 
 struct A {};
 
@@ -69,3 +68,19 @@
 struct T {};
 
 typedef T<nullptr, nullptr, nullptr, nullptr> NT;
+
+namespace test1 { 
+template<typename T, typename U> struct is_same {
+  static const bool value = false;
+};
+
+template<typename T> struct is_same<T, T> {
+  static const bool value = true;
+};
+
+void *g(void*);
+bool g(bool);
+
+// Test that we prefer g(void*) over g(bool).
+static_assert(is_same<decltype(g(nullptr)), void*>::value, "");
+}





More information about the cfe-commits mailing list