[PATCH] Fix PR middle-end/20030, fold_indirect_ref and non zero lower bounds

Andrew Pinski pinskia@physics.uc.edu
Fri Feb 18 02:13:00 GMT 2005


On Feb 17, 2005, at 1:26 PM, Richard Henderson wrote:

> On Thu, Feb 17, 2005 at 12:44:37PM -0500, Andrew Pinski wrote:
>> -	return build4 (ARRAY_REF, type, op, size_zero_node, NULL_TREE, 
>> NULL_TREE);
>> +	{
>> +	  tree min_val = TYPE_MIN_VALUE (TYPE_DOMAIN (optype));
>> +	  return build4 (ARRAY_REF, type, op, min_val, NULL_TREE, 
>> NULL_TREE);
>> +	}
>
> TYPE_DOMAIN isn't always set.  Neither is TYPE_MIN_VALUE.
> You need to check for nulls and use zero.

Good point.  I should have checked the documentation.

Bootstrapping and testing in process, ok if it passes?

Thanks,
Andrew Pinski

	* fold-const.c (fold_indirect_ref_1): Use the correct index for zero 
access,
	the lower bound of the array type if it exists.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: temp.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050218/160a0e7d/attachment.txt>
-------------- next part --------------


Testcase (modified from the pervious one to be able to commit the 
testsuite,
I was reminded that abort exists in gfortran):
       program foo
       character*1 a1, a2, b
       a1='A'
       a2='A'
       b='B'
       x = LSAME(a1,a2)
       if ( x.ne.1 ) then
         call abort  ();
       endif
       end

       logical function LSAME( CA, CB )
       character CA, CB
       integer   INTA, INTB
       INTA = ICHAR( CA )
       INTB = ICHAR( CB )
       LSAME = INTA.EQ.INTB
       end 


More information about the Gcc-patches mailing list