This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for 1.1.1 branch
- To: egcs-patches at cygnus dot com
- Subject: C++ PATCH for 1.1.1 branch
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Mon, 9 Nov 1998 09:35:07 -0800
- Cc: Jason Merrill <jason at cygnus dot com>, Jeff Law <law at cygnus dot com>
- Reply-to: mark at markmitchell dot com
I've put the following patch on the branch. This patch has been on
the mainline for a while now, and avoids crashes on code like:
struct X {
~X();
};
X::~X(int) {}
which for some reason seems to come up a lot on egcs-bugs.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
1998-11-08 Mark Mitchell <mark@markmitchell.com>
* decl.c (grokdeclarator): Tighten checks for invalid
destructors. Improve error-messages and error-recovery.
* decl2.c (check_classfn): Don't assume that mangled destructor
names contain type information.
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.152.2.11
diff -c -p -r1.152.2.11 decl.c
*** decl.c 1998/10/29 21:43:52 1.152.2.11
--- decl.c 1998/11/09 15:50:35
*************** grokdeclarator (declarator, declspecs, d
*** 9425,9432 ****
error ("destructor cannot be static member function");
if (quals)
{
! error ("destructors cannot be declared `const' or `volatile'");
! return void_type_node;
}
if (decl_context == FIELD)
{
--- 9425,9433 ----
error ("destructor cannot be static member function");
if (quals)
{
! cp_error ("destructors may not be `%s'",
! IDENTIFIER_POINTER (TREE_VALUE (quals)));
! quals = NULL_TREE;
}
if (decl_context == FIELD)
{
*************** grokdeclarator (declarator, declspecs, d
*** 9451,9458 ****
}
if (quals)
{
! error ("constructors cannot be declared `const' or `volatile'");
! return void_type_node;
}
{
RID_BIT_TYPE tmp_bits;
--- 9452,9460 ----
}
if (quals)
{
! cp_error ("constructors may not be `%s'",
! IDENTIFIER_POINTER (TREE_VALUE (quals)));
! quals = NULL_TREE;
}
{
RID_BIT_TYPE tmp_bits;
*************** grokdeclarator (declarator, declspecs, d
*** 9510,9533 ****
arg_types = grokparms (inner_parms, funcdecl_p ? funcdef_flag : 0);
! if (declarator)
{
! /* Get past destructors, etc.
! We know we have one because FLAGS will be non-zero.
!
! Complain about improper parameter lists here. */
if (TREE_CODE (declarator) == BIT_NOT_EXPR)
{
! declarator = TREE_OPERAND (declarator, 0);
!
! if (strict_prototype == 0 && arg_types == NULL_TREE)
! arg_types = void_list_node;
! else if (arg_types == NULL_TREE
! || arg_types != void_list_node)
! {
! error ("destructors cannot be specified with parameters");
! arg_types = void_list_node;
! }
}
}
--- 9512,9533 ----
arg_types = grokparms (inner_parms, funcdecl_p ? funcdef_flag : 0);
! if (declarator && flags == DTOR_FLAG)
{
! /* A destructor declared in the body of a class will
! be represented as a BIT_NOT_EXPR. But, we just
! want the underlying IDENTIFIER. */
if (TREE_CODE (declarator) == BIT_NOT_EXPR)
+ declarator = TREE_OPERAND (declarator, 0);
+
+ if (strict_prototype == 0 && arg_types == NULL_TREE)
+ arg_types = void_list_node;
+ else if (arg_types == NULL_TREE
+ || arg_types != void_list_node)
{
! cp_error ("destructors may not have parameters");
! arg_types = void_list_node;
! last_function_parms = NULL_TREE;
}
}
Index: decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.96.2.13
diff -c -p -r1.96.2.13 decl2.c
*** decl2.c 1998/11/02 22:25:05 1.96.2.13
--- decl2.c 1998/11/09 15:50:37
*************** check_classfn (ctype, function)
*** 1480,1488 ****
fndecl = OVL_CURRENT (fndecls);
/* The DECL_ASSEMBLER_NAME for a TEMPLATE_DECL is
not mangled, so the check below does not work
! correctly in that case. */
if (TREE_CODE (function) != TEMPLATE_DECL
&& TREE_CODE (fndecl) != TEMPLATE_DECL
&& (DECL_ASSEMBLER_NAME (function)
== DECL_ASSEMBLER_NAME (fndecl)))
return fndecl;
--- 1480,1491 ----
fndecl = OVL_CURRENT (fndecls);
/* The DECL_ASSEMBLER_NAME for a TEMPLATE_DECL is
not mangled, so the check below does not work
! correctly in that case. Since mangled destructor names
! do not include the type of the arguments, we
! can't use this short-cut for them, either. */
if (TREE_CODE (function) != TEMPLATE_DECL
&& TREE_CODE (fndecl) != TEMPLATE_DECL
+ && !DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (function))
&& (DECL_ASSEMBLER_NAME (function)
== DECL_ASSEMBLER_NAME (fndecl)))
return fndecl;