C++ PATCH for c++/80614, wrong mangling for C++17 noexcept type

Jason Merrill jason@redhat.com
Fri Jun 16 21:55:00 GMT 2017


My earlier patch for noexcept types preserved the noexcept in
canonicalize_for_substitution, but lost it in write_type.

Tested x86_64-pc-linux-gnu, applying to trunk and 7.
-------------- next part --------------
commit 152635968e18ec06da5308102c4859523c897707
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jun 16 14:23:54 2017 -0400

            PR c++/80614 - Wrong mangling for C++17 noexcept type
    
            * mangle.c (write_type): Put the eh spec back on the function type.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index e866675..c83aef5 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2100,6 +2100,11 @@ write_type (tree type)
 	  || TREE_CODE (t) == METHOD_TYPE)
 	{
 	  t = build_ref_qualified_type (t, type_memfn_rqual (type));
+	  if (flag_noexcept_type)
+	    {
+	      tree r = TYPE_RAISES_EXCEPTIONS (type);
+	      t = build_exception_variant (t, r);
+	    }
 	  if (abi_version_at_least (8)
 	      || type == TYPE_MAIN_VARIANT (type))
 	    /* Avoid adding the unqualified function type as a substitution.  */
diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type16.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type16.C
new file mode 100644
index 0000000..8c763a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type16.C
@@ -0,0 +1,11 @@
+// PR c++/80614
+// { dg-options -std=c++1z }
+
+template <typename T> void fn() {}
+
+int main() {
+  // { dg-final { scan-assembler "_Z2fnIKFvvEEvv" } }
+  fn<void() const>();
+  // { dg-final { scan-assembler "_Z2fnIKDoFvvEEvv" } }
+  fn<void() const noexcept>();
+}


More information about the Gcc-patches mailing list