This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Add sorry() when mangling CALL_EXPR
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Jun 2003 01:22:14 +0200
- Subject: [C++ PATCH] Add sorry() when mangling CALL_EXPR
Hello,
this patch adds a sorry() when write_expression meets a CALL_EXPR. Since
this is a defect in the C++ ABI, we currently have no way to mangle
correctly such an expression. This patch lets the compilation aborts
gracefully instead of segfaulting.
This issue was discussed here:
http://gcc.gnu.org/ml/gcc/2003-06/msg01948.html
This patch has been bootstrapped on i686-pc-cygwin (c, c++, java), and
regtested (together with my following patch) with "make check-g++" with no
new regressions. OK for mainline? I suggest to include this also in the
branch.
Giovanni Bajo
2003-06-25 Giovanni Bajo <giovannibajo@libero.it>
* mangle.c (write_expression): Exit gracefully when trying to
mangle a CALL_EXPR.
2003-06-25 Giovanni Bajo <giovannibajo@libero.it>
* g++.dg/other/error9.C: New test.
Index: mangle.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.68
diff -c -w -p -r1.68 mangle.c
*** mangle.c 3 Apr 2003 03:45:48 -0000 1.68
--- mangle.c 24 Jun 2003 22:56:27 -0000
*************** write_expression (expr)
*** 1986,1991 ****
--- 1986,1995 ----
switch (code)
{
+ case CALL_EXPR:
+ sorry ("call_expr cannot be mangled due to a defect in the C++
ABI");
+ break;
+
case CAST_EXPR:
write_type (TREE_TYPE (expr));
write_expression (TREE_VALUE (TREE_OPERAND (expr, 0)));
// { dg-do compile }
// Make sure we emit a decent error message when trying to mangle an
// expression not supported by the C++ ABI due to a defect.
template <int N>
struct A {};
struct B
{
static int foo(void);
};
template <class T>
A<sizeof(T::foo())> func(void);
int main()
{
func<B>(); // { dg-error "sorry, unimplemented" }
}