pr17399 [committed: Ada updates]

Richard Henderson rth@redhat.com
Mon Sep 13 18:40:00 GMT 2004


On Mon, Sep 13, 2004 at 12:23:01PM +0200, Arnaud Charlet wrote:
> +    case ADDR_EXPR:
> +      /* If we're taking the address of a constant CONSTRUCTOR, force it to
> +	 be put into static memory.  We know it's going to be readonly given
> +	 the semantics we have and it's required to be static memory in
> +	 the case when the reference is in an elaboration procedure.  */
> +      if (TREE_CODE (TREE_OPERAND (expr, 0)) == CONSTRUCTOR
> +	  && TREE_CONSTANT (TREE_OPERAND (expr, 0)))
> +	{
> +	  tree new_var
> +	    = create_tmp_var (TREE_TYPE (TREE_OPERAND (expr, 0)), "C");
> +
> +	  TREE_READONLY (new_var) = 1;
> +	  TREE_STATIC (new_var) = 1;
> +	  TREE_ADDRESSABLE (new_var) = 1;
> +
> +	  gimplify_and_add (build2 (MODIFY_EXPR, TREE_TYPE (new_var),
> +				    new_var, TREE_OPERAND (expr, 0)),
> +			    pre_p);

This will, of course, not work.  An *assignment* to read-only memory?
You may have wanted

	DECL_INITIAL (new_var) = TREE_OPERAND (expr, 0);

Or perhaps,

	if (TREE_CODE (TREE_OPERAND (expr, 0)) == CONSTRUCTOR)
	  {
	    tree new_var = ...

	    if (TREE_CONSTANT (TREE_OPERAND (expr, 0)))
	      {
		TREE_READONLY (new_var) = 1;
		DECL_INITIAL (new_var) = TREE_OPERAND (expr, 0);
	      }
	    else
	      gimplify_and_add (build2 (MODIFY_EXPR, TREE_TYPE (new_var),
					new_var, TREE_OPERAND (expr, 0)),
				pre_p);



r~



More information about the Gcc-patches mailing list