[Fortran, committed] Fix thinko in fix of PR 947.

Toon Moene toon@moene.indiv.nluug.nl
Wed Feb 13 03:51:00 GMT 2002


L.S.,

Well, test case g77.f-torture/execute/947.f didn't fail for nothing on
big-endian targets - my original solution to PR fortran/947 was wrong.

It turns out I was changing fields in a shared structure (ffebld is a
_pointer_ to a structure, not the structure itself).

Solved by the attached patch; make bootstrap (C and Fortran) and make
check (Fortran only) on i686-pc-linux-gnu and powerpc-unknown-linux-gnu.

It goes to show that little endian hardware is a device (pat. pend.) for
hiding programmer errors ...

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)
-------------- next part --------------
2002-02-13  Toon Moene  <toon@moene.indiv.nluug.nl>

	* data.c (ffedata_eval_offset_): Only convert index,
	low and high bound in data statements to default integer
	if they are constants.  Use a copy of the data structure.

*** data.c.orig	Sat Feb  9 19:27:24 2002
--- data.c	Wed Feb 13 05:52:33 2002
*************** ffedata_eval_offset_ (ffebld subscripts,
*** 979,982 ****
--- 979,983 ----
      {
        ffeinfoKindtype sub_kind, low_kind, hi_kind;
+       ffebld sub1, low1, hi1;
  
        ++rank;
*************** ffedata_eval_offset_ (ffebld subscripts,
*** 987,1000 ****
  
        assert (ffeinfo_basictype (ffebld_info (subscript)) == FFEINFO_basictypeINTEGER);
!       /* Force to default - it's a constant expression !  */
!       sub_kind = ffeinfo_kindtype (ffebld_info (subscript));
!       if (sub_kind == FFEINFO_kindtypeINTEGER2)
! 	subscript->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) subscript->u.conter.expr->u.integer2;
!       else if (sub_kind == FFEINFO_kindtypeINTEGER3)
! 	subscript->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) subscript->u.conter.expr->u.integer3;
!       else if (sub_kind == FFEINFO_kindtypeINTEGER4)
! 	subscript->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) subscript->u.conter.expr->u.integer4;
!       ffeinfo_kindtype (ffebld_info (subscript)) = FFEINFO_kindtypeINTEGERDEFAULT;
!       value = ffedata_eval_integer1_ (subscript);
  
        assert (ffebld_op (dim) == FFEBLD_opBOUNDS);
--- 988,1004 ----
  
        assert (ffeinfo_basictype (ffebld_info (subscript)) == FFEINFO_basictypeINTEGER);
!       if (ffebld_op (subscript) == FFEBLD_opCONTER)
! 	{
! 	  /* Force to default - it's a constant expression !  */
! 	  sub_kind = ffeinfo_kindtype (ffebld_info (subscript));
! 	  sub1 = ffebld_new_conter_with_orig (ffebld_constant_new_integer1_val (
! 		   sub_kind == FFEINFO_kindtypeINTEGER2 ? subscript->u.conter.expr->u.integer2 :
! 		   sub_kind == FFEINFO_kindtypeINTEGER3 ? subscript->u.conter.expr->u.integer3 :
! 		   sub_kind == FFEINFO_kindtypeINTEGER4 ? subscript->u.conter.expr->u.integer4 :
! 			subscript->u.conter.expr->u.integer1), NULL);
! 	  value = ffedata_eval_integer1_ (sub1);
! 	}
!       else
! 	value = ffedata_eval_integer1_ (subscript);
  
        assert (ffebld_op (dim) == FFEBLD_opBOUNDS);
*************** ffedata_eval_offset_ (ffebld subscripts,
*** 1007,1033 ****
  	{
  	  assert (ffeinfo_basictype (ffebld_info (low)) == FFEINFO_basictypeINTEGER);
! 	  /* Force to default - it's a constant expression !  */
! 	  low_kind = ffeinfo_kindtype (ffebld_info (low));
! 	  if (low_kind == FFEINFO_kindtypeINTEGER2)
! 	    low->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) low->u.conter.expr->u.integer2;
! 	  else if (low_kind == FFEINFO_kindtypeINTEGER3)
! 	    low->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) low->u.conter.expr->u.integer3;
! 	  else if (low_kind == FFEINFO_kindtypeINTEGER4)
! 	    low->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) low->u.conter.expr->u.integer4;
! 	  ffeinfo_kindtype (ffebld_info (low)) = FFEINFO_kindtypeINTEGERDEFAULT;
! 	  lowbound = ffedata_eval_integer1_ (low);
  	}
  
        assert (ffeinfo_basictype (ffebld_info (high)) == FFEINFO_basictypeINTEGER);
!       /* Force to default - it's a constant expression !  */
!       hi_kind = ffeinfo_kindtype (ffebld_info (high));
!       if (hi_kind == FFEINFO_kindtypeINTEGER2)
! 	high->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) high->u.conter.expr->u.integer2;
!       else if (hi_kind == FFEINFO_kindtypeINTEGER3)
! 	high->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) high->u.conter.expr->u.integer3;
!       else if (hi_kind == FFEINFO_kindtypeINTEGER4)
! 	high->u.conter.expr->u.integer1 = (ffetargetIntegerDefault) high->u.conter.expr->u.integer4;
!       ffeinfo_kindtype (ffebld_info (high)) = FFEINFO_kindtypeINTEGERDEFAULT;
!       highbound = ffedata_eval_integer1_ (high);
  
        if ((value < lowbound) || (value > highbound))
--- 1011,1043 ----
  	{
  	  assert (ffeinfo_basictype (ffebld_info (low)) == FFEINFO_basictypeINTEGER);
! 	  if (ffebld_op (low) == FFEBLD_opCONTER)
! 	    {
! 	      /* Force to default - it's a constant expression !  */
! 	      low_kind = ffeinfo_kindtype (ffebld_info (low));
! 	      low1 = ffebld_new_conter_with_orig (ffebld_constant_new_integer1_val (
! 			low_kind == FFEINFO_kindtypeINTEGER2 ? low->u.conter.expr->u.integer2 :
! 			low_kind == FFEINFO_kindtypeINTEGER3 ? low->u.conter.expr->u.integer3 :
! 			low_kind == FFEINFO_kindtypeINTEGER4 ? low->u.conter.expr->u.integer4 :
! 				low->u.conter.expr->u.integer1), NULL);
! 	       lowbound = ffedata_eval_integer1_ (low1);
! 	     }
! 	   else
! 	     lowbound = ffedata_eval_integer1_ (low);
  	}
  
        assert (ffeinfo_basictype (ffebld_info (high)) == FFEINFO_basictypeINTEGER);
!       if (ffebld_op (high) == FFEBLD_opCONTER)
! 	{
! 	  /* Force to default - it's a constant expression !  */
! 	  hi_kind = ffeinfo_kindtype (ffebld_info (high));
! 	  hi1 = ffebld_new_conter_with_orig (ffebld_constant_new_integer1_val (
! 		   hi_kind == FFEINFO_kindtypeINTEGER2 ? high->u.conter.expr->u.integer2 :
! 		   hi_kind == FFEINFO_kindtypeINTEGER3 ? high->u.conter.expr->u.integer3 :
! 		   hi_kind == FFEINFO_kindtypeINTEGER4 ? high->u.conter.expr->u.integer4 :
! 			high->u.conter.expr->u.integer1), NULL);
! 	  highbound = ffedata_eval_integer1_ (hi1);
! 	}
!       else
! 	highbound = ffedata_eval_integer1_ (high);
  
        if ((value < lowbound) || (value > highbound))


More information about the Gcc-patches mailing list