Make NullPtr.h compile with clang -std=c++11 and libstdc++4.2
authorthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2012 07:14:28 +0000 (07:14 +0000)
committerthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2012 07:14:28 +0000 (07:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83999

Reviewed by Sam Weinig.

Before this patch, NullPtr.h assumed that a working |nullptr| implied
a working |std::nullptr_t| as well. With clang and libstdc++4.2, this
is not true.

I tested (-stdlib=libc++, -stdlib=libstdc++) x (-std=c++11, -std=c++03)
with clang.

* wtf/NullPtr.h:
(std):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114227 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/NullPtr.h

index 86375a9..6fe3190 100644 (file)
@@ -1,3 +1,20 @@
+2012-04-16  Nico Weber  <thakis@chromium.org>
+
+        Make NullPtr.h compile with clang -std=c++11 and libstdc++4.2
+        https://bugs.webkit.org/show_bug.cgi?id=83999
+
+        Reviewed by Sam Weinig.
+
+        Before this patch, NullPtr.h assumed that a working |nullptr| implied
+        a working |std::nullptr_t| as well. With clang and libstdc++4.2, this
+        is not true.
+
+        I tested (-stdlib=libc++, -stdlib=libstdc++) x (-std=c++11, -std=c++03)
+        with clang.
+
+        * wtf/NullPtr.h:
+        (std):
+
 2012-04-14  Sam Weinig  <sam@webkit.org>
 
         Harden WTF::ByteArray::create()
index 9463feb..98c0514 100644 (file)
@@ -37,12 +37,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <cstddef>
 
+// libstdc++ supports nullptr_t starting with gcc 4.6.
+#if defined(__GLIBCXX__) && __GLIBCXX__ < 20110325
+namespace std {
+typedef decltype(nullptr) nullptr_t;
+}
+#endif
+
 #else
 
 namespace std {
-     class WTF_EXPORT_PRIVATE nullptr_t { };
+class WTF_EXPORT_PRIVATE nullptr_t { };
 }
-
 extern WTF_EXPORT_PRIVATE std::nullptr_t nullptr;
 
 #endif