[PATCH] PR14841 and PR15838

Richard Henderson rth@redhat.com
Tue Aug 31 21:35:00 GMT 2004


On Tue, Aug 31, 2004 at 07:16:16PM +0200, Steven Bosscher wrote:
> +   return (TREE_CODE (var) == VAR_DECL
> + 	  && TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE
> + 	  && TREE_READONLY (var)
> + 	  && DECL_INITIAL (var)
> + 	  && TREE_CODE (DECL_INITIAL (var)) == CONSTRUCTOR
> + 	  && ! TREE_SIDE_EFFECTS (DECL_INITIAL (var)));

This test is not complete.  You need to check targetm.binds_local_p.
You ought to be checking TREE_STATIC.  The TREE_SIDE_EFFECTS check
is pointless.

> +   return (TREE_CODE (var) == VAR_DECL
> + 	  && TREE_CODE (TREE_TYPE (var)) == RECORD_TYPE
> + 	  && TREE_CODE (TREE_OPERAND (t, 1)) == FIELD_DECL
> + 	  && TREE_READONLY (var)
> + 	  && DECL_INITIAL (var)
> + 	  && TREE_CODE (DECL_INITIAL (var)) == CONSTRUCTOR
> + 	  && ! TREE_SIDE_EFFECTS (DECL_INITIAL (var)));

The variable test is largely replicated here -- bad.

You're not handling nested components/arrays.  Try

	x = a.b.c.d.e[2].f[4].g

All of this should be done in fold or fold_stmt, so that passes
other than ccp can make use of it.



r~



More information about the Gcc-patches mailing list