]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/54208 (compilation error for ubound construct in PARAMETER statements)
authorMikael Morin <mikael@gcc.gnu.org>
Wed, 12 Sep 2012 21:54:50 +0000 (21:54 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Wed, 12 Sep 2012 21:54:50 +0000 (21:54 +0000)
fortran/
PR fortran/54208
* simplify.c (simplify_bound_dim): Resolve array spec before
proceeding with simplification.

testsuite/
PR fortran/54208
* gfortran.dg/bound_simplification_3.f90: New test.

From-SVN: r191233

gcc/fortran/ChangeLog
gcc/fortran/simplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/bound_simplification_3.f90 [new file with mode: 0644]

index 28f27db020e68658e97b41bd62f7290ce3e02b5b..fa1f36449740f8fc91f4a11ea3757b27f2bb8698 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-12  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/54208
+       * simplify.c (simplify_bound_dim): Resolve array spec before
+       proceeding with simplification.
+
 2012-07-14  Mikael Morin  <mikael@gcc.gnu.org>
 
        Backport from trunk:
index 0780a778e0fa187d38643eb94720199e5e04eb40..5fe5d1db1a0ff72add7dd57b5f16d1d92b69758b 100644 (file)
@@ -3296,6 +3296,9 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kind, int d, int upper,
   gcc_assert (array->expr_type == EXPR_VARIABLE);
   gcc_assert (as);
 
+  if (gfc_resolve_array_spec (as, 0) == FAILURE)
+    return NULL;
+
   /* The last dimension of an assumed-size array is special.  */
   if ((!coarray && d == as->rank && as->type == AS_ASSUMED_SIZE && !upper)
       || (coarray && d == as->rank + as->corank))
index 559857a04f4e073804804694c441f6a484cf6f60..aa13012bb43c7862f16f6788565a6e9fe23814ab 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-12  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/54208
+       * gfortran.dg/bound_simplification_3.f90: New test.
+
 2012-09-10  Markus Trippelsdorf  <markus@trippelsdorf.de>
 
        PR middle-end/54515
diff --git a/gcc/testsuite/gfortran.dg/bound_simplification_3.f90 b/gcc/testsuite/gfortran.dg/bound_simplification_3.f90
new file mode 100644 (file)
index 0000000..de3a3dc
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! PR fortran/54208
+! The I and J definitions used to raise an error because ARR's array spec
+! was resolved to late for the LBOUND and UBOUND calls to be simplified to
+! a constant.
+!
+! Contributed by Carlos A. Cruz <carlos.a.cruz@nasa.gov>
+
+program testit
+  integer, parameter :: n=2
+  integer, dimension(1-min(n,2)/2:n) :: arr
+  integer, parameter :: i=lbound(arr,1)
+  integer, parameter :: j=ubound(arr,1)
+  ! write(6,*) i, j
+  if (i /= 0) call abort
+  if (j /= 2) call abort
+end program testit
+
+! { dg-final { scan-tree-dump-times "bound" 0 "original" } }
+! { dg-final { scan-tree-dump-times "abort" 0 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }