This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to dependent call mangling
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 31 Mar 2009 12:51:56 -0400
- Subject: C++ PATCH to dependent call mangling
I noticed that we were mangling a call to a dependent name using the
symbol name of the first element of the overload set, which was clearly
wrong. This patch changes it to just use the source name.
Tested x86_64-pc-linux-gnu, applied to trunk and 4.4.
2009-03-31 Jason Merrill <jason@redhat.com>
* mangle.c (write_expression): Mangle dependent name as
source-name.
Index: cp/mangle.c
===================================================================
*** cp/mangle.c (revision 145359)
--- cp/mangle.c (working copy)
*************** write_expression (tree expr)
*** 2159,2170 ****
code = TREE_CODE (expr);
}
- if (code == OVERLOAD)
- {
- expr = OVL_FUNCTION (expr);
- code = TREE_CODE (expr);
- }
-
/* Handle pointers-to-members by making them look like expression
nodes. */
if (code == PTRMEM_CST)
--- 2159,2164 ----
*************** write_expression (tree expr)
*** 2344,2350 ****
switch (code)
{
case CALL_EXPR:
! write_expression (CALL_EXPR_FN (expr));
for (i = 0; i < call_expr_nargs (expr); ++i)
write_expression (CALL_EXPR_ARG (expr, i));
write_char ('E');
--- 2338,2362 ----
switch (code)
{
case CALL_EXPR:
! {
! tree fn = CALL_EXPR_FN (expr);
!
! if (TREE_CODE (fn) == ADDR_EXPR)
! fn = TREE_OPERAND (fn, 0);
!
! /* Mangle a dependent name as the name, not whatever happens to
! be the first function in the overload set. */
! if ((TREE_CODE (fn) == FUNCTION_DECL
! || TREE_CODE (fn) == OVERLOAD)
! && type_dependent_expression_p_push (expr))
! fn = DECL_NAME (get_first_fn (fn));
!
! if (TREE_CODE (fn) == IDENTIFIER_NODE)
! write_source_name (fn);
! else
! write_expression (fn);
! }
!
for (i = 0; i < call_expr_nargs (expr); ++i)
write_expression (CALL_EXPR_ARG (expr, i));
write_char ('E');
Index: testsuite/g++.dg/cpp0x/auto6.C
===================================================================
*** testsuite/g++.dg/cpp0x/auto6.C (revision 145291)
--- testsuite/g++.dg/cpp0x/auto6.C (working copy)
*************** int main()
*** 101,107 ****
auto i4 = add4(1, 2.0);
// { dg-final { scan-assembler "_Z4add2IidEDTplcvT__EcvT0__EES0_S1_" } }
auto i2 = add2(1, 2.0);
! // { dg-final { scan-assembler "_Z4add3IidEDTclL_Z2agEfp_fp0_EET_T0_" } }
auto i3 = add3(1, 2.0);
// { dg-final { scan-assembler "_Z1fI1AIiEEDTclptfp_1fEEPT_" } }
f(p);
--- 101,107 ----
auto i4 = add4(1, 2.0);
// { dg-final { scan-assembler "_Z4add2IidEDTplcvT__EcvT0__EES0_S1_" } }
auto i2 = add2(1, 2.0);
! // { dg-final { scan-assembler "_Z4add3IidEDTcl2agfp_fp0_EET_T0_" } }
auto i3 = add3(1, 2.0);
// { dg-final { scan-assembler "_Z1fI1AIiEEDTclptfp_1fEEPT_" } }
f(p);
Index: testsuite/g++.dg/cpp0x/auto12.C
===================================================================
*** testsuite/g++.dg/cpp0x/auto12.C (revision 145291)
--- testsuite/g++.dg/cpp0x/auto12.C (working copy)
*************** int main()
*** 58,63 ****
A<int>().h(1);
// { dg-final { scan-assembler "_ZN1AIiE1jIiEEDTplfp_clL_Z1xvEEET_" } }
A<int>().j(1);
! // { dg-final { scan-assembler "_Z1gIIidEEDTclL_Z1fEspplfp_Li1EEEDpT_" } }
g(42, 1.0);
}
--- 58,63 ----
A<int>().h(1);
// { dg-final { scan-assembler "_ZN1AIiE1jIiEEDTplfp_clL_Z1xvEEET_" } }
A<int>().j(1);
! // { dg-final { scan-assembler "_Z1gIIidEEDTcl1fspplfp_Li1EEEDpT_" } }
g(42, 1.0);
}