C++ patch for tree inlining bug with dynamic arrays
Jim Wilson
wilson@cygnus.com
Tue Jan 25 21:02:00 GMT 2000
Winsup (the cygwin library) fails to compile with the new inlining on trees
code. The problem is a dynamic array in an inline function. Here is a
minimal testcase.
extern void __inline__
sub (int i)
{
volatile char a[i];
return;
}
void
sub2 ()
{
sub (100);
}
The VAR_DECL for A contains SAVE_EXPRs that need to be remapped so that the
SAVE_EXPR_CONTEXT field will be set correctly after inlining. Here is a
patch that seems to work fine. I tested this by doing a build of winsup
(but didn't try to run any code on an NT system to test the build).
Tue Jan 25 19:24:36 2000 Jim Wilson <wilson@cygnus.com>
* cp/optimize.c (remap_decl): Add walk_tree calls for DECL_SIZE (t)
and TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (t))).
Index: optimize.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/optimize.c,v
retrieving revision 1.2
diff -p -r1.2 optimize.c
*** optimize.c 2000/01/03 19:18:42 1.2
--- optimize.c 2000/01/26 03:26:03
*************** remap_decl (decl, id)
*** 104,109 ****
--- 104,118 ----
/* Make a copy of the variable or label. */
t = copy_decl_for_inlining (decl, fn,
VARRAY_TREE (id->fns, 0));
+
+ /* The decl T could be a dynamic array or other variable size type,
+ in which case some fields need to be remapped because they may
+ contain SAVE_EXPRs. */
+ walk_tree (&DECL_SIZE (t), copy_body_r, id);
+ if (TREE_TYPE (t) && TYPE_DOMAIN (TREE_TYPE (t)))
+ walk_tree (&TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (t))),
+ copy_body_r, id);
+
/* Remember it, so that if we encounter this local entity
again we can reuse this copy. */
n = splay_tree_insert (id->decl_map,
More information about the Gcc-patches
mailing list