This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix minor bugs in tree-inline.c
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 3 Jul 04 10:51:45 EDT
- Subject: Fix minor bugs in tree-inline.c
These fix bugs that came up when running the ACATS suite.
The discussion about mutually-recursive pointers came up with some other
approaches, but what I did is the simplest and there's no point doing
too much work for a case that won't occur in any real code.
Tested on x86_64-linux-gnu.
2004-07-03 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* tree-inline.c (initialize_inlined_parameters): Pass proper function
context to gimplify_body.
(walk_tree): Don't walk into types twice.
(walk_tree, case POINTER_TYPE): Deal with mutually recursive pointers.
*** tree-inline.c 1 Jul 2004 00:01:23 -0000 1.118
--- tree-inline.c 2 Jul 2004 18:47:48 -0000
*************** initialize_inlined_parameters (inline_da
*** 865,869 ****
if (gimplify_init_stmts_p && lang_hooks.gimple_before_inlining)
! gimplify_body (&init_stmts, fn);
declare_inline_vars (bind_expr, vars);
--- 865,869 ----
if (gimplify_init_stmts_p && lang_hooks.gimple_before_inlining)
! gimplify_body (&init_stmts, current_function_decl);
declare_inline_vars (bind_expr, vars);
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 2040,2056 ****
tree type = TREE_TYPE (decl);
! /* Walk into fields of the DECL if it's not a type, then into fields
! of the type in both cases. */
!
! if (TREE_CODE (decl) != TYPE_DECL
! && TREE_CODE (decl) != FIELD_DECL && TREE_CODE (decl) != PARM_DECL)
{
! WALK_SUBTREE (DECL_INITIAL (decl));
WALK_SUBTREE (DECL_SIZE (decl));
! WALK_SUBTREE (DECL_SIZE_UNIT (decl));
}
! /* First do the common fields via recursion, then the fields we only
! do when we are declaring the type or object. */
WALK_SUBTREE (type);
WALK_SUBTREE (TYPE_SIZE (type));
--- 2040,2056 ----
tree type = TREE_TYPE (decl);
! /* Walk into fields of the DECL if it's not a type. */
! if (TREE_CODE (decl) != TYPE_DECL)
{
! if (TREE_CODE (decl) != FIELD_DECL && TREE_CODE (decl) != PARM_DECL)
! WALK_SUBTREE (DECL_INITIAL (decl));
!
WALK_SUBTREE (DECL_SIZE (decl));
! WALK_SUBTREE_TAIL (DECL_SIZE_UNIT (decl));
}
! /* Otherwise, we are declaring a type. First do the common fields via
! recursion, then the fields we only do when we are declaring the type
! or object. */
WALK_SUBTREE (type);
WALK_SUBTREE (TYPE_SIZE (type));
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 2200,2203 ****
--- 2200,2225 ----
case POINTER_TYPE:
case REFERENCE_TYPE:
+ /* We have to worry about mutually recursive pointers. These can't
+ be written in C. They can in Ada. It's pathlogical, but
+ there's an ACATS test (c38102a) that checks it. Deal with this
+ by checking if we're pointing to another pointer, that one
+ points to another pointer, that one does too, and we have no htab.
+ If so, get a hash table. We check three levels deep to avoid
+ the cost of the hash table if we don't need one. */
+ if (POINTER_TYPE_P (TREE_TYPE (*tp))
+ && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*tp)))
+ && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (TREE_TYPE (*tp))))
+ && !htab)
+ {
+ result = walk_tree_without_duplicates (&TREE_TYPE (*tp),
+ func, data);
+ if (result)
+ return result;
+
+ break;
+ }
+
+ /* ... fall through ... */
+
case COMPLEX_TYPE:
WALK_SUBTREE_TAIL (TREE_TYPE (*tp));