Patchwork [Fortran] PR56849 - Fix RESHAPE shape checking with order=

login
register
mail settings
Submitter Tobias Burnus
Date April 7, 2013, 8:11 a.m.
Message ID <51612A44.3010007@net-b.de>
Download mbox | patch
Permalink /patch/234464/
State New
Headers show

Comments

Tobias Burnus - April 7, 2013, 8:11 a.m.
A rather obvious patch after one realizes that order= doesn't affect shape=.

Build & regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
Janus Weil - April 7, 2013, 8:35 a.m.
2013/4/7 Tobias Burnus <burnus@net-b.de>:
> A rather obvious patch after one realizes that order= doesn't affect shape=.

Right.


> Build & regtested on x86-64-gnu-linux.
> OK for the trunk?

Yes, thanks for the patch!

Cheers,
Janus

Patch

2013-04-07  Tobias Burnus  <burnus@net-b.de>

	PR fortran/56849
	* iresolve.c (gfc_resolve_reshape): Set shape also
	with order=.

2013-04-07  Tobias Burnus  <burnus@net-b.de>

	PR fortran/56849
	* gfortran.dg/reshape_5.f90: New.

diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index 2b92b7c..af452b3 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -2154,10 +2154,7 @@  gfc_resolve_reshape (gfc_expr *f, gfc_expr *source, gfc_expr *shape,
       break;
     }
 
-  /* TODO: Make this work with a constant ORDER parameter.  */
-  if (shape->expr_type == EXPR_ARRAY
-      && gfc_is_constant_expr (shape)
-      && order == NULL)
+  if (shape->expr_type == EXPR_ARRAY && gfc_is_constant_expr (shape))
     {
       gfc_constructor *c;
       f->shape = gfc_get_shape (f->rank);
diff --git a/gcc/testsuite/gfortran.dg/reshape_5.f90 b/gcc/testsuite/gfortran.dg/reshape_5.f90
new file mode 100644
index 0000000..a7d4a3f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/reshape_5.f90
@@ -0,0 +1,10 @@ 
+! { dg-do compile }
+!
+! PR fortran/56849
+!
+integer :: x(2,2),y(4)
+y = reshape([1,2,3,4],[4])
+x(:,1:1) = reshape(y(::2), [1,2], order=[1,2]) ! { dg-error "Different shape for array assignment at .1. on dimension 1 .2 and 1." }
+print *, y
+print *, x(:,1)
+end