This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR14841 and PR15838


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]