This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC [ABI]: C++ PATCH for c++/44540 - avoid mangling attribute noreturn

The ICE in PR 44540 called attention to a long-standing mangling bug: attributes noreturn and const are represented internally as TYPE_VOLATILE and TYPE_CONST on FUNCTION_TYPE, and we were emitting them as cv-quals on the mangled form of the function type in a parameter of pointer-to-function type. Clearly this is wrong, as they aren't part of the type system, and a declaration which didn't use the attributes would mangle differently.

The testcase was derived from the systemtap sources, where the relevant declaration has C linkage, so it would not be affected by this change. But it is an ABI change.


commit c22c049821b367a80c65b3fce9a1e196ef63f956
Author: Jason Merrill <>
Date:   Thu Jul 1 14:32:58 2010 -0400

    	PR c++/44540
    	* mangle.c (write_CV_qualifiers_for_type): Ignore TYPE_QUALS on

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index e825952..40b21b9 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -1978,6 +1978,11 @@ write_CV_qualifiers_for_type (const tree type)
      array.  */
   cp_cv_quals quals = TYPE_QUALS (type);
+  /* Attribute const/noreturn are not reflected in mangling.  */
+  if (TREE_CODE (type) == FUNCTION_TYPE
+      || TREE_CODE (type) == METHOD_TYPE)
+    return 0;
   if (quals & TYPE_QUAL_RESTRICT)
       write_char ('r');
diff --git a/gcc/testsuite/g++.dg/ext/noreturn1.C b/gcc/testsuite/g++.dg/ext/noreturn1.C
new file mode 100644
index 0000000..11e0aed
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/noreturn1.C
@@ -0,0 +1,13 @@
+// Test that attribute noreturn is not part of the mangled name.
+void baz (const char *fmt, ...);
+// { dg-final { scan-assembler "_Z3barPFvPKczE" } }
+void bar (void (*baz) (const char *fmt, ...)
+			   __attribute__ ((noreturn, format (printf, 1, 2))));
+foo ()
+  bar (&baz);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]