re PR c++/39095 (Mangling changes break ABI)

PR c++/39095
	* operators.def: Use COMPONENT_REF code for ->/pt operator again,
	remove ./dt operator.
	* mangle.c (write_expression): Handle COMPONENT_REF after handling
	ADDR_EXPR, for COMPONENT_REF without ARROW_EXPR inside of it
	write_string ("dt") instead of using operators.def.

	* g++.dg/abi/mangle31.C: New test.

From-SVN: r143933
This commit is contained in:
Jakub Jelinek 2009-02-04 17:50:22 +01:00 committed by Jakub Jelinek
parent 5b43bf058b
commit ee429f8459
5 changed files with 67 additions and 16 deletions

View File

@ -1,3 +1,12 @@
2009-02-04 Jakub Jelinek <jakub@redhat.com>
PR c++/39095
* operators.def: Use COMPONENT_REF code for ->/pt operator again,
remove ./dt operator.
* mangle.c (write_expression): Handle COMPONENT_REF after handling
ADDR_EXPR, for COMPONENT_REF without ARROW_EXPR inside of it
write_string ("dt") instead of using operators.def.
2009-02-03 Jason Merrill <jason@redhat.com>
* typeck.c (cp_build_unary_op): Only complain about taking address

View File

@ -2298,20 +2298,6 @@ write_expression (tree expr)
write_template_args (template_args);
}
}
else if (code == COMPONENT_REF)
{
tree ob = TREE_OPERAND (expr, 0);
if (TREE_CODE (ob) == ARROW_EXPR)
{
code = ARROW_EXPR;
ob = TREE_OPERAND (ob, 0);
}
write_string (operator_name_info[(int)code].mangled_name);
write_expression (ob);
write_member_name (TREE_OPERAND (expr, 1));
}
else
{
int i;
@ -2334,6 +2320,23 @@ write_expression (tree expr)
code = TREE_CODE (expr);
}
if (code == COMPONENT_REF)
{
tree ob = TREE_OPERAND (expr, 0);
if (TREE_CODE (ob) == ARROW_EXPR)
{
write_string (operator_name_info[(int)code].mangled_name);
ob = TREE_OPERAND (ob, 0);
}
else
write_string ("dt");
write_expression (ob);
write_member_name (TREE_OPERAND (expr, 1));
return;
}
/* If it wasn't any of those, recursively expand the expression. */
write_string (operator_name_info[(int) code].mangled_name);

View File

@ -125,8 +125,7 @@ DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", 2)
DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", 2)
DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", 2)
DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", 2)
DEF_SIMPLE_OPERATOR ("->", ARROW_EXPR, "pt", 2)
DEF_SIMPLE_OPERATOR (".", COMPONENT_REF, "dt", 2)
DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", 2)
DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", 2)
DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", 2)
DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", 2)

View File

@ -1,3 +1,8 @@
2009-02-04 Jakub Jelinek <jakub@redhat.com>
PR c++/39095
* g++.dg/abi/mangle31.C: New test.
2009-02-03 Joseph Myers <joseph@codesourcery.com>
PR c/29129

View File

@ -0,0 +1,35 @@
// PR c++/39095
// { dg-do compile }
struct B
{
int b;
};
struct A
{
B *operator->();
A ();
B b;
};
A::A ()
{
}
B *
A::operator->()
{
return &b;
}
A a;
int
foo ()
{
return a->b;
}
// { dg-final { scan-assembler "_ZN1AptEv" } }
// { dg-final { scan-assembler-not "_ZN1AdtEv" } }