PR c++/80614 - Wrong mangling for C++17 noexcept type
authorJason Merrill <jason@redhat.com>
Sat, 17 Jun 2017 02:28:06 +0000 (22:28 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 17 Jun 2017 02:28:06 +0000 (22:28 -0400)
* mangle.c (write_type): Put the eh spec back on the function type.

From-SVN: r249321

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/testsuite/g++.dg/cpp1z/noexcept-type16.C [new file with mode: 0644]

index 2d47d7b4a7f4a0b5dd67bb7f84bba0d685c4c16a..66dd04427003d0a4bc8aad0099a9c140761565ab 100644 (file)
@@ -1,5 +1,8 @@
 2017-06-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/80614 - Wrong mangling for C++17 noexcept type
+       * mangle.c (write_type): Put the eh spec back on the function type.
+
        PR c++/81102 - Wrong error with partial specialization.
        * pt.c (unify) [TEMPLATE_PARM_INDEX]: Strip reference when comparing
        types.  Do type deduction later.
index e866675bed957c8bc38dfc358678da9be3b7999d..c83aef5ede4bf37d26b00f5f9f93601bbed5d485 100644 (file)
@@ -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 (file)
index 0000000..8c763a5
--- /dev/null
@@ -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>();
+}