]> granicus.if.org Git - clang/commitdiff
[ItaniumMangle] Fix mangling of GNU __null in an expression to match GCC
authorJames Clarke <jrtc27@jrtc27.com>
Tue, 8 Oct 2019 02:28:57 +0000 (02:28 +0000)
committerJames Clarke <jrtc27@jrtc27.com>
Tue, 8 Oct 2019 02:28:57 +0000 (02:28 +0000)
Reviewers: rsmith

Reviewed By: rsmith

Subscribers: erik.pilkington, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68368

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

lib/AST/ItaniumMangle.cpp
test/CodeGenCXX/mangle-exprs.cpp

index bea96dec9da97a8c6343b5de8e3760f53619998d..c6f7143251a6f8eee35db381fbc2d808088fa537 100644 (file)
@@ -4273,8 +4273,11 @@ recurse:
   }
 
   case Expr::GNUNullExprClass:
-    // FIXME: should this really be mangled the same as nullptr?
-    // fallthrough
+    // Mangle as if an integer literal 0.
+    Out << 'L';
+    mangleType(E->getType());
+    Out << "0E";
+    break;
 
   case Expr::CXXNullPtrLiteralExprClass: {
     Out << "LDnE";
index 6c46402694036e10f4b72777354888a913f4020b..1b99272b7f22a7392920a873893040490686f167 100644 (file)
@@ -373,3 +373,19 @@ namespace designated_init {
   template<typename T> void f(decltype(T{.a.b[3][1 ... 4] = 9}) x) {}
   void use_f(A a) { f<A>(a); }
 }
+
+namespace null {
+  template <decltype(nullptr) P>
+  void cpp_nullptr(typename enable_if<P == nullptr>::type* = 0) {
+  }
+
+  template <void *P>
+  void gnu_null(typename enable_if<P == __null>::type* = 0) {
+  }
+
+  // CHECK-LABEL: define {{.*}} @_ZN4null11cpp_nullptrILDn0EEEvPN9enable_ifIXeqT_LDnEEvE4typeE
+  template void cpp_nullptr<nullptr>(void *);
+
+  // CHECK-LABEL: define {{.*}} @_ZN4null8gnu_nullILPv0EEEvPN9enable_ifIXeqT_Ll0EEvE4typeE
+  template void gnu_null<nullptr>(void *);
+}