mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-05 01:34:12 +08:00
mangle.c (write_expression): Handle CAST_EXPR, STATIC_CAST_EXPR, CONST_CAST_EXPR.
* mangle.c (write_expression): Handle CAST_EXPR, STATIC_CAST_EXPR, CONST_CAST_EXPR. * operators.def: Add CAST_EXPR, STATIC_CAST_EXPR, CONST_CAST_EXPR. From-SVN: r47135
This commit is contained in:
parent
6f684b5368
commit
873ff98777
@ -1,3 +1,9 @@
|
||||
2001-11-17 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
* mangle.c (write_expression): Handle CAST_EXPR, STATIC_CAST_EXPR,
|
||||
CONST_CAST_EXPR.
|
||||
* operators.def: Add CAST_EXPR, STATIC_CAST_EXPR, CONST_CAST_EXPR.
|
||||
|
||||
2001-11-16 Neil Booth <neil@daikokuya.demon.co.uk>
|
||||
|
||||
* cp-tree.h (print_class_statistics): Restore.
|
||||
|
@ -1818,18 +1818,32 @@ write_expression (expr)
|
||||
/* If it wasn't any of those, recursively expand the expression. */
|
||||
write_string (operator_name_info[(int) code].mangled_name);
|
||||
|
||||
/* Handle pointers-to-members specially. */
|
||||
if (code == SCOPE_REF)
|
||||
switch (code)
|
||||
{
|
||||
case CAST_EXPR:
|
||||
write_type (TREE_TYPE (expr));
|
||||
write_expression (TREE_VALUE (TREE_OPERAND (expr, 0)));
|
||||
break;
|
||||
|
||||
case STATIC_CAST_EXPR:
|
||||
case CONST_CAST_EXPR:
|
||||
write_type (TREE_TYPE (expr));
|
||||
write_expression (TREE_OPERAND (expr, 0));
|
||||
break;
|
||||
|
||||
/* Handle pointers-to-members specially. */
|
||||
case SCOPE_REF:
|
||||
write_type (TREE_OPERAND (expr, 0));
|
||||
if (TREE_CODE (TREE_OPERAND (expr, 1)) == IDENTIFIER_NODE)
|
||||
write_source_name (TREE_OPERAND (expr, 1));
|
||||
else
|
||||
write_encoding (TREE_OPERAND (expr, 1));
|
||||
break;
|
||||
|
||||
default:
|
||||
for (i = 0; i < TREE_CODE_LENGTH (code); ++i)
|
||||
write_expression (TREE_OPERAND (expr, i));
|
||||
}
|
||||
else
|
||||
for (i = 0; i < TREE_CODE_LENGTH (code); ++i)
|
||||
write_expression (TREE_OPERAND (expr, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,9 @@ DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "v17alignof", 1)
|
||||
|
||||
/* The cast operator. */
|
||||
DEF_SIMPLE_OPERATOR ("", TYPE_EXPR, "cv", 1)
|
||||
DEF_SIMPLE_OPERATOR ("", CAST_EXPR, "cv", 1)
|
||||
DEF_SIMPLE_OPERATOR ("", CONST_CAST_EXPR, "cv", 1)
|
||||
DEF_SIMPLE_OPERATOR ("", STATIC_CAST_EXPR, "cv", 1)
|
||||
|
||||
/* Binary operators. */
|
||||
DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", 2)
|
||||
|
19
gcc/testsuite/g++.dg/abi/mangle3.C
Normal file
19
gcc/testsuite/g++.dg/abi/mangle3.C
Normal file
@ -0,0 +1,19 @@
|
||||
// Test mangling of type casts
|
||||
// { dg-do compile }
|
||||
|
||||
template<int i> class A {};
|
||||
template<bool b> class B {};
|
||||
|
||||
template<int i> void f(A<i> &, B<bool(i)> &) {}
|
||||
template<int i> void g(A<i> &, B<static_cast<bool>(i)> &) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
A<1> a;
|
||||
B<true> b;
|
||||
f(a, b);
|
||||
g(a, b);
|
||||
}
|
||||
|
||||
// { dg-final { scan-assembler "\n_?_Z1fILi1EEvR1AIXT_EER1BIXcvbT_EE\[: \t\n\]" } }
|
||||
// { dg-final { scan-assembler "\n_?_Z1gILi1EEvR1AIXT_EER1BIXcvbT_EE\[: \t\n\]" } }
|
26
gcc/testsuite/g++.dg/abi/mangle4.C
Normal file
26
gcc/testsuite/g++.dg/abi/mangle4.C
Normal file
@ -0,0 +1,26 @@
|
||||
// Test mangling of type casts
|
||||
// { dg-do compile }
|
||||
|
||||
class A {};
|
||||
class B : A {};
|
||||
|
||||
template<const A* a> class C {};
|
||||
template<const B* b> class D {};
|
||||
template<B* b> class E {};
|
||||
|
||||
template<const B* b> void f(D<b> &, C<static_cast<const A*>(b)> &) {}
|
||||
template<const B* b> void g(D<b> &, E<const_cast<B*>(b)> &) {}
|
||||
|
||||
B b;
|
||||
|
||||
int main()
|
||||
{
|
||||
C<static_cast<const A*>(&b)> c;
|
||||
D<&b> d;
|
||||
E<const_cast<B*>(&b)> e;
|
||||
f(d, c);
|
||||
g(d, e);
|
||||
}
|
||||
|
||||
// { dg-final { scan-assembler "\n_?_Z1fIXadL_Z1bEEEvR1DIXT_EER1CIXcvPK1AT_EE\[: \t\n\]" } }
|
||||
// { dg-final { scan-assembler "\n_?_Z1gIXadL_Z1bEEEvR1DIXT_EER1EIXcvP1BT_EE\[: \t\n\]" } }
|
Loading…
Reference in New Issue
Block a user