]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/71730 (ICE when character length specification uses an undefi...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 29 Sep 2016 00:18:44 +0000 (00:18 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 29 Sep 2016 00:18:44 +0000 (00:18 +0000)
2016-09-28  Steven G. Kargl  <kargl@gcc.gnu.org>

backport from trunk
PR fortran/71730
* gfortran.dg/pr71730.f90: New test.
* gfortran.dg/bounds_check_strlen_2.f90: Fix invalid code.
* gfortran.dg/array_constructor_27.f03: Update dg-error message.
* gfortran.dg/array_constructor_26.f03: Ditto.

PR fortran/77612
* gfortran.dg/pr77612.f90: New test.

2016-09-28  Steven G. Kargl  <kargl@gcc.gnu.org>

backport from trunk
PR fortran/71730
* decl.c (char_len_param_value): Check return value of
gfc_reduce_init_expr().

PR fortran/77612
* decl.c (char_len_param_value): Check parent namespace for
seen_implicit_none.

From-SVN: r240608

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/array_constructor_26.f03
gcc/testsuite/gfortran.dg/array_constructor_27.f03
gcc/testsuite/gfortran.dg/bounds_check_strlen_2.f90
gcc/testsuite/gfortran.dg/pr71730.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr77612.f90 [new file with mode: 0644]

index 03603d5ed4fdde59678d99c16450e380382ed75e..6df115ead6cef483bdc96b6440f50deff99dff8f 100644 (file)
@@ -1,3 +1,14 @@
+2016-09-28  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       backport from trunk
+       PR fortran/71730
+       * decl.c (char_len_param_value): Check return value of
+       gfc_reduce_init_expr().
+
+       PR fortran/77612
+       * decl.c (char_len_param_value): Check parent namespace for 
+       seen_implicit_none.
+
 2016-09-28  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        backport from trunk
index d4704d32dfdf7fe7e81573293e651fcd89e1f874..d6327189f10cbfec2eb2d322d11b632f03ff1fb9 100644 (file)
@@ -759,6 +759,7 @@ char_len_param_value (gfc_expr **expr, bool *deferred)
     goto syntax;
   else if ((*expr)->expr_type == EXPR_VARIABLE)
     {
+      bool t;
       gfc_expr *e;
 
       e = gfc_copy_expr (*expr);
@@ -770,7 +771,16 @@ char_len_param_value (gfc_expr **expr, bool *deferred)
          && e->ref->u.ar.dimen_type[0] == DIMEN_RANGE)
        goto syntax;
 
-      gfc_reduce_init_expr (e);
+      t = gfc_reduce_init_expr (e);
+
+      if (!t && e->ts.type == BT_UNKNOWN
+         && e->symtree->n.sym->attr.untyped == 1
+         && (e->symtree->n.sym->ns->seen_implicit_none == 1
+             || e->symtree->n.sym->ns->parent->seen_implicit_none == 1))
+       {
+         gfc_free_expr (e);
+         goto syntax;
+       }
 
       if ((e->ref && e->ref->type == REF_ARRAY
           && e->ref->u.ar.type != AR_ELEMENT) 
index ea7198a0ad4c40db3fae21a13a7fc2145816980f..9ffbfff73da44a4b13b64811a12129bd4e438b69 100644 (file)
@@ -1,3 +1,15 @@
+2016-09-28  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       backport from trunk
+       PR fortran/71730
+       * gfortran.dg/pr71730.f90: New test.
+       * gfortran.dg/bounds_check_strlen_2.f90: Fix invalid code.
+       * gfortran.dg/array_constructor_27.f03: Update dg-error message.
+       * gfortran.dg/array_constructor_26.f03: Ditto.
+
+       PR fortran/77612
+       * gfortran.dg/pr77612.f90: New test.
+
 2016-09-28  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        backport from trunk
index 9993099af917c3f8141521681141696f1562d1e3..bb40d09d090c8335d7b0f5bc0665c7e61545f99d 100644 (file)
@@ -10,7 +10,6 @@ MODULE WinData
   INTEGER (1), PARAMETER :: MAXFLD = 25_1, MAXHED = 5_1, MAXCHR = 80_1
   integer :: i
   TYPE TWindowData
-    CHARACTER (MAX_FLD_HED, 1) :: DWFdHd(MAXFLD) = [(" ", i = 1, MAXFLD)]
-    ! { dg-error "specification expression" "" { target *-*-* } 13 }
+    CHARACTER (MAX_FLD_HED, 1) :: DWFdHd(MAXFLD) = [(" ", i = 1, MAXFLD)] ! { dg-error "Scalar INTEGER expression" }
   END TYPE TWindowData
 END MODULE WinData
index 21adac82ad459cfdec10423bc6819d362c64898d..de0217a750028327d05959402b2044181a0c02e3 100644 (file)
@@ -8,8 +8,7 @@
 implicit none
 
 type t
-  character (a) :: arr (1) = [ "a" ]
-  ! { dg-error "specification expression" "" { target *-*-* } 11 }
+  character (a) :: arr (1) = [ "a" ] ! { dg-error "Scalar INTEGER expression" }
 end type t
 
 end
index 241db66239cd990b6602dfcfe01848830f2fbb07..73c2ea8282ea76c9ca9260ec3d9a5497f0b1f096 100644 (file)
@@ -11,8 +11,8 @@ CONTAINS
 
   SUBROUTINE test (str, n)
     IMPLICIT NONE
-    CHARACTER(len=n) :: str
     INTEGER :: n
+    CHARACTER(len=n) :: str
   END SUBROUTINE test
 
   SUBROUTINE test2 (str)
diff --git a/gcc/testsuite/gfortran.dg/pr71730.f90 b/gcc/testsuite/gfortran.dg/pr71730.f90
new file mode 100644 (file)
index 0000000..f0d48c4
--- /dev/null
@@ -0,0 +1,5 @@
+! { dg-do compile }
+subroutine foo
+  implicit none
+  character(len=bar) :: a ! { dg-error "Scalar INTEGER expression" }
+end subroutine foo
diff --git a/gcc/testsuite/gfortran.dg/pr77612.f90 b/gcc/testsuite/gfortran.dg/pr77612.f90
new file mode 100644 (file)
index 0000000..7bc5a49
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do compile }
+
+program bad_len
+
+  implicit none
+
+contains
+
+  subroutine sub
+    character(len = ICE) :: line ! { dg-error "INTEGER expression expected" }
+  end subroutine
+
+end program