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] Fix some type errors


On Wed, 18 May 2005, Richard Henderson wrote:

> On Wed, May 18, 2005 at 05:46:29PM +0200, Richard Guenther wrote:
> > ! 				  fold_convert (char_type_node,
> > ! 					        build1 (INDIRECT_REF, itype,
> > ! 					                TREE_VALUE (arglist))),
>
> Any reason not to use build_fold_indirect_ref here?  Then
> we're absolutely sure that the type is correct.
>
>
> > ! 				  fold_convert (char_type_node,
> > ! 					        integer_zero_node));
>
> build_int_cst (char_type_node, 0);

Here's a revised patch, now that the build_fold_indirect_ref fixes
have gone in.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for mainline?

Thanks,
Richard.


2005-05-30  Richard Guenther  <rguenth@gcc.gnu.org>

	* fold-const.c (fold_binary): Fix type of created
	INDIRECT_REF node.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.583
diff -c -3 -p -r1.583 fold-const.c
*** fold-const.c	27 May 2005 17:23:30 -0000	1.583
--- fold-const.c	30 May 2005 07:44:36 -0000
*************** fold_binary (enum tree_code code, tree t
*** 9892,9902 ****
  	      && (arglist = TREE_OPERAND (arg0, 1))
  	      && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE
  	      && ! TREE_CHAIN (arglist))
! 	    return fold_build2 (code, type,
! 				build1 (INDIRECT_REF, char_type_node,
! 					TREE_VALUE (arglist)),
! 				fold_convert (char_type_node,
! 					      integer_zero_node));
  	}

        /* We can fold X/C1 op C2 where C1 and C2 are integer constants
--- 9892,9903 ----
  	      && (arglist = TREE_OPERAND (arg0, 1))
  	      && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE
  	      && ! TREE_CHAIN (arglist))
! 	    {
! 	      tree iref = build_fold_indirect_ref (TREE_VALUE (arglist));
! 	      return fold_build2 (code, type,
! 				  fold_convert (char_type_node, iref),
! 				  build_int_cst (char_type_node, 0));
! 	    }
  	}

        /* We can fold X/C1 op C2 where C1 and C2 are integer constants



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