From d9634d537130407bc8ea2ada9508e2386e1b714b Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 2 Jul 2004 23:56:38 +0000 Subject: [PATCH] re PR c++/16240 (g++ generates incorrect mangled name) 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 | 3 +++ gcc/cp/mangle.c | 16 ++++++++++++---- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/abi/mangle22.C | 9 +++++++++ gcc/testsuite/g++.dg/abi/mangle23.C | 9 +++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/abi/mangle22.C create mode 100644 gcc/testsuite/g++.dg/abi/mangle23.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e226c7da48d..8e21875e4c8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2004-07-02 Mark Mitchell + PR c++/16240 + * mangle.c (write_template_arg): Correct mangling. + PR c++/16297 * decl.c (grokdeclarator): Robustify. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 81ac4ad1b22..97d4309fcf2 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -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'); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9aeee5ce7eb..8638c0ed646 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2004-07-02 Mark Mitchell + + 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 index 00000000000..93ddd1e8740 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle22.C @@ -0,0 +1,9 @@ +// PR c++/16240 +// { dg-options "-fabi-version=3" } + +void foo(char); +template struct CB {}; + +void g(CB 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 index 00000000000..c17f54b4a72 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle23.C @@ -0,0 +1,9 @@ +// PR c++/16240 +// { dg-options "-fabi-version=2" } + +void foo(char); +template struct CB {}; + +void g(CB i) {} + +// { dg-final { scan-assembler "\n_?_Z1g2CBILZ3foocEE\[: \t\n\]" } } -- 2.30.2