Patchwork [Fortran] PR 52093 - fix simplification of SIZE((x))

login
register
mail settings
Submitter Tobias Burnus
Date Feb. 2, 2012, 9:04 p.m.
Message ID <4F2AFA71.9020408@net-b.de>
Download mbox | patch
Permalink /patch/139218/
State New
Headers show

Comments

Tobias Burnus - Feb. 2, 2012, 9:04 p.m.
Dear all,

I have committed the attached patch as obvious (Rev.183848) - after 
building and regtesting on x86-64-linux.

I intent to backport it to 4.6 soon. (It's a regression.)

Tobias

Patch

2012-02-02  Tobias Burnus  <burnus@net-b.de>

	PR fortran/52093
	* simplify.c (gfc_simplify_size): Handle INTRINSIC_PARENTHESES.

2012-02-02  Tobias Burnus  <burnus@net-b.de>

	PR fortran/52093
	* gfortran.dg/shape_7.f90: New.

Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c	(Revision 183846)
+++ gcc/fortran/simplify.c	(Arbeitskopie)
@@ -5541,6 +5541,7 @@  gfc_simplify_size (gfc_expr *array, gfc_expr *dim,
 	  case INTRINSIC_NOT:
 	  case INTRINSIC_UPLUS:
 	  case INTRINSIC_UMINUS:
+	  case INTRINSIC_PARENTHESES:
 	    replacement = array->value.op.op1;
 	    break;
 
Index: gcc/testsuite/gfortran.dg/shape_7.f90
===================================================================
--- gcc/testsuite/gfortran.dg/shape_7.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/shape_7.f90	(Arbeitskopie)
@@ -0,0 +1,32 @@ 
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! PR fortran/52093
+!
+! Contributed by Mohammad Rahmani
+!
+
+Program Main
+ Implicit None
+ Integer:: X(2,2)
+ Integer:: X2(7:11,8:9)
+
+ if (size((X)) /= 4) call abort ()
+ if (any (Shape((X))  /= [2,2])) call abort ()
+ if (any (lbound((X)) /= [1,1])) call abort ()
+ if (any (ubound((X)) /= [2,2])) call abort ()
+
+ if (size(X2) /= 10) call abort ()
+ if (any (Shape(X2)  /= [5,2])) call abort ()
+ if (any (lbound(X2) /= [7,8]))  call abort ()
+ if (any (ubound(X2) /= [11,9])) call abort ()
+
+ if (size((X2)) /= 10) call abort ()
+ if (any (Shape((X2))  /= [5,2])) call abort ()
+ if (any (lbound((X2)) /= [1,1])) call abort ()
+ if (any (ubound((X2)) /= [5,2])) call abort ()
+End Program Main
+
+! { dg-final { scan-tree-dump-times "abort" 0 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }
+