Patchwork C++ PATCH for c++/52706 (nullptr_t mangling)

login
register
mail settings
Submitter Jason Merrill
Date April 15, 2012, 5:03 p.m.
Message ID <4F8AFF5E.7080805@redhat.com>
Download mbox | patch
Permalink /patch/152673/
State New
Headers show

Comments

Jason Merrill - April 15, 2012, 5:03 p.m.
We were incorrectly treating nullptr_t as a substitutable type.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit d13e197a238f2cbcca283e8d2332ea75af00b297
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Apr 13 17:34:31 2012 -0400

    	PR c++/52706
    	* mangle.c (write_type): nullptr_t is a builtin type.

diff --git a/gcc/common.opt b/gcc/common.opt
index 39f1679..ee0c66a 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -788,6 +788,8 @@  Driver Undocumented
 ;    argument.
 ;    First selectable in G++ 4.7.
 ;
+; 7: The version of the ABI that treats nullptr_t as a builtin type.
+;    First selectable in G++ 4.8.
 ; Additional positive integers will be assigned as new versions of
 ; the ABI become the default version of the ABI.
 fabi-version=
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 1536828..d00df1f 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2023,6 +2023,8 @@  write_type (tree type)
 
 	    case NULLPTR_TYPE:
 	      write_string ("Dn");
+	      if (abi_version_at_least (7))
+		++is_builtin_type;
 	      break;
 
 	    case TYPEOF_TYPE:
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr27.C b/gcc/testsuite/g++.dg/cpp0x/nullptr27.C
new file mode 100644
index 0000000..1b86868
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr27.C
@@ -0,0 +1,8 @@ 
+// PR c++/52706
+// { dg-options "-std=c++11 -fabi-version=0" }
+// { dg-final { scan-assembler "_Z1fIDnLDn0EEiT_" } }
+
+template<class T, decltype(nullptr) = nullptr>
+int f(T);
+
+int i2 = f(nullptr); // 17