This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Re: [C++] SEGV in mapcar() with a CALL_EXPR
- To: drow at false dot org
- Subject: Re: [PATCH] Re: [C++] SEGV in mapcar() with a CALL_EXPR
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 17 Aug 1999 00:24:40 -0700
- Cc: gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <19990804131959.A4656@them.org><19990806185129.A32012@them.org>
Here's a patch for this problem. Check in on the mainline.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-08-17 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (CALL_DECLARATOR_PARMS): New macro.
(CALL_DECLARATOR_QUALS): Likewise.
(CALL_DECARATOR_EXCEPTION_SPEC): Likewise.
* decl.c (grokdeclarator): Adjust to use them.
* decl2.c (grokfield): Likewise.
(reparse_absdcl_as_casts): Likewise.
* lex.c (make_call_declarator): Likewise.
(set_quals_and_spec): Likewise.
* pt.c (tsubst): Likewise.
* tree.c (mapcar): Remove special hack to handle third operand of
a CALL_EXPR.
Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.263
diff -c -p -r1.263 cp-tree.h
*** cp-tree.h 1999/08/14 09:23:24 1.263
--- cp-tree.h 1999/08/17 06:57:37
*************** extern int flag_new_for_scope;
*** 2147,2152 ****
--- 2147,2164 ----
#define STMT_LINENO(NODE) \
(TREE_COMPLEXITY ((NODE)))
+ /* The parameters for a call-declarator. */
+ #define CALL_DECLARATOR_PARMS(NODE) \
+ (TREE_PURPOSE (TREE_OPERAND ((NODE), 1)))
+
+ /* The cv-qualifiers for a call-declarator. */
+ #define CALL_DECLARATOR_QUALS(NODE) \
+ (TREE_VALUE (TREE_OPERAND ((NODE), 1)))
+
+ /* The exception-specification for a call-declarator. */
+ #define CALL_DECLARATOR_EXCEPTION_SPEC(NODE) \
+ (TREE_TYPE ((NODE)))
+
/* An enumeration of the kind of tags that C++ accepts. */
enum tag_types { record_type, class_type, union_type, enum_type };
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.406
diff -c -p -r1.406 decl.c
*** decl.c 1999/08/14 09:23:26 1.406
--- decl.c 1999/08/17 06:57:46
*************** grokdeclarator (declarator, declspecs, d
*** 8996,9002 ****
break;
case CALL_EXPR:
! if (parmlist_is_exprlist (TREE_OPERAND (decl, 1)))
{
/* This is actually a variable declaration using
constructor syntax. We need to call start_decl and
--- 8996,9002 ----
break;
case CALL_EXPR:
! if (parmlist_is_exprlist (CALL_DECLARATOR_PARMS (decl)))
{
/* This is actually a variable declaration using
constructor syntax. We need to call start_decl and
*************** grokdeclarator (declarator, declspecs, d
*** 9006,9012 ****
tree attributes, prefix_attributes;
*next = TREE_OPERAND (decl, 0);
! init = TREE_OPERAND (decl, 1);
if (attrlist)
{
--- 9006,9012 ----
tree attributes, prefix_attributes;
*next = TREE_OPERAND (decl, 0);
! init = CALL_DECLARATOR_PARMS (decl);
if (attrlist)
{
*************** grokdeclarator (declarator, declspecs, d
*** 10017,10023 ****
{
tree arg_types;
int funcdecl_p;
! tree inner_parms = TREE_OPERAND (declarator, 1);
tree inner_decl = TREE_OPERAND (declarator, 0);
/* Declaring a function type.
--- 10017,10023 ----
{
tree arg_types;
int funcdecl_p;
! tree inner_parms = CALL_DECLARATOR_PARMS (declarator);
tree inner_decl = TREE_OPERAND (declarator, 0);
/* Declaring a function type.
*************** grokdeclarator (declarator, declspecs, d
*** 10047,10056 ****
inner_decl = dname;
/* Pick up type qualifiers which should be applied to `this'. */
! quals = TREE_OPERAND (declarator, 2);
/* Pick up the exception specifications. */
! raises = TREE_TYPE (declarator);
/* Say it's a definition only for the CALL_EXPR
closest to the identifier. */
--- 10047,10056 ----
inner_decl = dname;
/* Pick up type qualifiers which should be applied to `this'. */
! quals = CALL_DECLARATOR_QUALS (declarator);
/* Pick up the exception specifications. */
! raises = CALL_DECLARATOR_EXCEPTION_SPEC (declarator);
/* Say it's a definition only for the CALL_EXPR
closest to the identifier. */
Index: decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.234
diff -c -p -r1.234 decl2.c
*** decl2.c 1999/08/14 09:23:27 1.234
--- decl2.c 1999/08/17 06:57:49
*************** grokfield (declarator, declspecs, init,
*** 1590,1596 ****
&& TREE_OPERAND (declarator, 0)
&& (TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE
|| TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
! && parmlist_is_exprlist (TREE_OPERAND (declarator, 1)))
{
init = TREE_OPERAND (declarator, 1);
declarator = TREE_OPERAND (declarator, 0);
--- 1590,1596 ----
&& TREE_OPERAND (declarator, 0)
&& (TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE
|| TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
! && parmlist_is_exprlist (CALL_DECLARATOR_PARMS (declarator)))
{
init = TREE_OPERAND (declarator, 1);
declarator = TREE_OPERAND (declarator, 0);
*************** reparse_absdcl_as_casts (decl, expr)
*** 3754,3760 ****
if (TREE_CODE (expr) == CONSTRUCTOR
&& TREE_TYPE (expr) == 0)
{
! type = groktypename (TREE_VALUE (TREE_OPERAND (decl, 1)));
decl = TREE_OPERAND (decl, 0);
expr = digest_init (type, expr, (tree *) 0);
--- 3754,3760 ----
if (TREE_CODE (expr) == CONSTRUCTOR
&& TREE_TYPE (expr) == 0)
{
! type = groktypename (TREE_VALUE (CALL_DECLARATOR_PARMS (decl)));
decl = TREE_OPERAND (decl, 0);
expr = digest_init (type, expr, (tree *) 0);
*************** reparse_absdcl_as_casts (decl, expr)
*** 3768,3774 ****
while (decl)
{
! type = groktypename (TREE_VALUE (TREE_OPERAND (decl, 1)));
decl = TREE_OPERAND (decl, 0);
expr = build_c_cast (type, expr);
}
--- 3768,3774 ----
while (decl)
{
! type = groktypename (TREE_VALUE (CALL_DECLARATOR_PARMS (decl)));
decl = TREE_OPERAND (decl, 0);
expr = build_c_cast (type, expr);
}
Index: lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.135
diff -c -p -r1.135 lex.c
*** lex.c 1999/08/14 09:23:28 1.135
--- lex.c 1999/08/17 06:57:52
*************** tree
*** 228,235 ****
make_call_declarator (target, parms, cv_qualifiers, exception_specification)
tree target, parms, cv_qualifiers, exception_specification;
{
! target = build_parse_node (CALL_EXPR, target, parms, cv_qualifiers);
! TREE_TYPE (target) = exception_specification;
return target;
}
--- 228,242 ----
make_call_declarator (target, parms, cv_qualifiers, exception_specification)
tree target, parms, cv_qualifiers, exception_specification;
{
! target = build_parse_node (CALL_EXPR, target,
! /* Both build_parse_node and
! decl_tree_cons build on the
! temp_decl_obstack. */
! decl_tree_cons (parms, cv_qualifiers, NULL_TREE),
! /* The third operand is really RTL. We
! shouldn't put anything there. */
! NULL_TREE);
! CALL_DECLARATOR_EXCEPTION_SPEC (target) = exception_specification;
return target;
}
*************** void
*** 237,244 ****
set_quals_and_spec (call_declarator, cv_qualifiers, exception_specification)
tree call_declarator, cv_qualifiers, exception_specification;
{
! TREE_OPERAND (call_declarator, 2) = cv_qualifiers;
! TREE_TYPE (call_declarator) = exception_specification;
}
/* Build names and nodes for overloaded operators. */
--- 244,251 ----
set_quals_and_spec (call_declarator, cv_qualifiers, exception_specification)
tree call_declarator, cv_qualifiers, exception_specification;
{
! CALL_DECLARATOR_QUALS (call_declarator) = cv_qualifiers;
! CALL_DECLARATOR_EXCEPTION_SPEC (call_declarator) = exception_specification;
}
/* Build names and nodes for overloaded operators. */
Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.330
diff -c -p -r1.330 pt.c
*** pt.c 1999/08/16 00:59:19 1.330
--- pt.c 1999/08/17 06:57:57
*************** tsubst (t, args, complain, in_decl)
*** 6800,6814 ****
{
tree e1 = tsubst (TREE_OPERAND (t, 0), args, complain,
in_decl);
! tree e2 = tsubst_call_declarator_parms (TREE_OPERAND (t, 1), args,
! complain, in_decl);
! tree e3 = tsubst (TREE_TYPE (t), args, complain, in_decl);
if (e1 == error_mark_node || e2 == error_mark_node
|| e3 == error_mark_node)
return error_mark_node;
! return make_call_declarator (e1, e2, TREE_OPERAND (t, 2), e3);
}
case SCOPE_REF:
--- 6800,6815 ----
{
tree e1 = tsubst (TREE_OPERAND (t, 0), args, complain,
in_decl);
! tree e2 = (tsubst_call_declarator_parms
! (CALL_DECLARATOR_PARMS (t), args, complain, in_decl));
! tree e3 = tsubst (CALL_DECLARATOR_EXCEPTION_SPEC (t), args,
! complain, in_decl);
if (e1 == error_mark_node || e2 == error_mark_node
|| e3 == error_mark_node)
return error_mark_node;
! return make_call_declarator (e1, e2, CALL_DECLARATOR_QUALS (t), e3);
}
case SCOPE_REF:
Index: tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.129
diff -c -p -r1.129 tree.c
*** tree.c 1999/08/14 09:23:48 1.129
--- tree.c 1999/08/17 06:57:59
*************** mapcar (t, func)
*** 1938,1951 ****
TREE_TYPE (t) = mapcar (TREE_TYPE (t), func);
TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
!
! /* tree.def says that operand two is RTL, but
! make_call_declarator puts trees in there. */
! if (TREE_OPERAND (t, 2)
! && TREE_CODE (TREE_OPERAND (t, 2)) == TREE_LIST)
! TREE_OPERAND (t, 2) = mapcar (TREE_OPERAND (t, 2), func);
! else
! TREE_OPERAND (t, 2) = NULL_TREE;
return t;
case CONVERT_EXPR:
--- 1938,1944 ----
TREE_TYPE (t) = mapcar (TREE_TYPE (t), func);
TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
! TREE_OPERAND (t, 2) = NULL_TREE;
return t;
case CONVERT_EXPR: