re PR c++/16240 (g++ generates incorrect mangled name)
authorMark Mitchell <mark@codesourcery.com>
Fri, 2 Jul 2004 23:56:38 +0000 (23:56 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 2 Jul 2004 23:56:38 +0000 (23:56 +0000)
PR c++/16240
* mangle.c (write_template_arg): Correct mangling.

PR c++/16240
* g++.dg/abi/mangle22.C: New test.
* g++.dg/abi/mangle23.C: Likewise.

From-SVN: r84033

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/mangle22.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/mangle23.C [new file with mode: 0644]

index e226c7da48dfb069bfd88b3ad11befef7778efd7..8e21875e4c892f7300e4f58409087679c62c1804 100644 (file)
@@ -1,5 +1,8 @@
 2004-07-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/16240
+       * mangle.c (write_template_arg): Correct mangling.
+
        PR c++/16297
        * decl.c (grokdeclarator): Robustify.
 
index 81ac4ad1b220c92ac5b55ea29fce35cbf54b82ec..97d4309fcf278b1fe3e20d7f86f8d0c3b697d468 100644 (file)
@@ -2203,12 +2203,20 @@ write_template_arg (tree node)
     write_template_arg_literal (node);
   else if (DECL_P (node))
     {
-      /* G++ 3.2 incorrectly mangled non-type template arguments of
-        enumeration type using their names.  */
-      if (code == CONST_DECL)
+      /* Until ABI version 2, non-type template arguments of
+        enumeration type were mangled using their names.  */ 
+      if (code == CONST_DECL && !abi_version_at_least (2))
        G.need_abi_warning = 1;
       write_char ('L');
-      write_char ('Z');
+      /* Until ABI version 3, the underscore before the mangled name
+        was incorrectly omitted.  */
+      if (!abi_version_at_least (3))
+       {
+         G.need_abi_warning = 1;
+         write_char ('Z');
+       }
+      else
+       write_string ("_Z");
       write_encoding (node);
       write_char ('E');
     }
index 9aeee5ce7eb19a7a5e7049b25983d8c069bcfefd..8638c0ed6462b083842b3ea56eecc850435e0b8e 100644 (file)
@@ -1,3 +1,9 @@
+2004-07-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/16240
+       * g++.dg/abi/mangle22.C: New test.
+       * g++.dg/abi/mangle23.C: Likewise.
+
 2004-07-02  David Billinghurst  (David.Billinghurst@riotinto.com)
 
        PR fortran/16290
diff --git a/gcc/testsuite/g++.dg/abi/mangle22.C b/gcc/testsuite/g++.dg/abi/mangle22.C
new file mode 100644 (file)
index 0000000..93ddd1e
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/16240
+// { dg-options "-fabi-version=3" }
+
+void foo(char);
+template<void (&)(char)> struct CB {};
+
+void g(CB<foo> i) {}
+
+// { dg-final { scan-assembler "\n_?_Z1g2CBIL_Z3foocEE\[: \t\n\]" } }
diff --git a/gcc/testsuite/g++.dg/abi/mangle23.C b/gcc/testsuite/g++.dg/abi/mangle23.C
new file mode 100644 (file)
index 0000000..c17f54b
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/16240
+// { dg-options "-fabi-version=2" }
+
+void foo(char);
+template<void (&)(char)> struct CB {};
+
+void g(CB<foo> i) {}
+
+// { dg-final { scan-assembler "\n_?_Z1g2CBILZ3foocEE\[: \t\n\]" } }