]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran : ICE in gfc_validate_kind PR95586
authorMark Eggleston <markeggleston@gcc.gnu.org>
Wed, 10 Jun 2020 15:18:23 +0000 (16:18 +0100)
committerMark Eggleston <markeggleston@gcc.gnu.org>
Tue, 23 Jun 2020 06:07:23 +0000 (07:07 +0100)
Report syntax error for invalid letter-spec in IMPLICIT statements
for derived types and not an ICE.

Original patch by Steve Kargl.  Added test cases based on those
provided by G. Steinmetz  in the PR.

2020-06-23  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran/

PR fortran/95586
* decl.c (gfc_match_implicit): Only perform else branch if
the type spect is not BT_DERIVED.

2020-06-23  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

PR fortran/95586
* gfortran.dg/pr95586_1.f90: New test.
* gfortran.dg/pr95586_2.f90: New test.

gcc/fortran/decl.c
gcc/testsuite/gfortran.dg/pr95586_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr95586_2.f90 [new file with mode: 0644]

index c8a98537e87630a8dcbcd47601d87021eba535a5..c27cfacf2e4ec10d98a300d6ec38e1cdb79de068 100644 (file)
@@ -4827,7 +4827,7 @@ gfc_match_implicit (void)
       /* Last chance -- check <TYPE> <SELECTOR> (<RANGE>).  */
       if (ts.type == BT_CHARACTER)
        m = gfc_match_char_spec (&ts);
-      else
+      else if (ts.type != BT_DERIVED)
        {
          m = gfc_match_kind_spec (&ts, false);
          if (m == MATCH_NO)
diff --git a/gcc/testsuite/gfortran.dg/pr95586_1.f90 b/gcc/testsuite/gfortran.dg/pr95586_1.f90
new file mode 100644 (file)
index 0000000..009eb3e
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+!
+
+program test
+  implicit type(t) (1)  ! { dg-error "Syntax error" }
+  type t
+  end type
+end program
+
diff --git a/gcc/testsuite/gfortran.dg/pr95586_2.f90 b/gcc/testsuite/gfortran.dg/pr95586_2.f90
new file mode 100644 (file)
index 0000000..81ea6e9
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+
+program test
+  integer, parameter :: n1 = 1
+  implicit type(t) (n1)  ! { dg-error "Syntax error" }
+  type t
+  end type
+end program
+
+