From: Mark Mitchell Date: Sun, 16 May 1999 19:31:51 +0000 (+0000) Subject: cp-tree.h (permanent_p): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=88b117b74048dfb8fab4ba46a44da3ac995f597b;p=gcc.git cp-tree.h (permanent_p): New function. * cp-tree.h (permanent_p): New function. * init.c (build_new_1): Use mapcar, not copy_node, to copy a possibly complex tree node. * tree.c (mapcar): Adjust comments, and follow coding standards in conditional. (permanent_p): New function. From-SVN: r26951 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ceb0df70f6c..2a16a395bc4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +1999-05-16 Mark Mitchell + + * cp-tree.h (permanent_p): New function. + * init.c (build_new_1): Use mapcar, not copy_node, to copy a + possibly complex tree node. + * tree.c (mapcar): Adjust comments, and follow coding standards in + conditional. + (permanent_p): New function. + 1999-05-13 Per Bothner * class.c (push_lang_context): Turn off DECL_IGNORED_P for diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 955bf0a0e97..7c517c0dbdc 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3357,6 +3357,7 @@ extern char *lang_printable_name PROTO((tree, int)); extern tree build_exception_variant PROTO((tree, tree)); extern tree copy_template_template_parm PROTO((tree)); extern tree copy_to_permanent PROTO((tree)); +extern tree permanent_p PROTO((tree)); extern void print_lang_statistics PROTO((void)); extern void __eprintf PROTO((const char *, const char *, unsigned, const char *)); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 39736ce9199..7fb203007de 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2430,7 +2430,7 @@ build_new_1 (exp) } /* Copy size to the saveable obstack. */ - size = copy_node (size); + size = mapcar (size, permanent_p); cleanup = build_op_delete_call (dcode, alloc_node, size, flags, fn); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9012810d051..bf16fe2a0c5 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1724,10 +1724,8 @@ no_linkage_check (t) } -/* Subroutine of copy_to_permanent - - Assuming T is a node build bottom-up, make it all exist on - permanent obstack, if it is not permanent already. */ +/* Make copies of all the nodes below T. If FUNC is non-NULL, call it + for each node. */ tree mapcar (t, func) @@ -1739,8 +1737,12 @@ mapcar (t, func) if (t == NULL_TREE) return t; - if (tmp = func (t), tmp != NULL_TREE) - return tmp; + if (func) + { + tmp = func (t); + if (tmp) + return tmp; + } switch (TREE_CODE (t)) { @@ -1984,6 +1986,16 @@ mapcar (t, func) return NULL_TREE; } +/* Returns T if T is allocated on the permanent obstack, NULL_TREE + otherwise. */ + +tree +permanent_p (t) + tree t; +{ + return TREE_PERMANENT (t) ? t : NULL_TREE; +} + static tree perm_manip (t) tree t;