Fortran : ICE in gfc_validate_kind PR96099
authorMark Eggleston <markeggleston@gcc.gnu.org>
Thu, 1 Oct 2020 10:14:09 +0000 (11:14 +0100)
committerMark Eggleston <markeggleston@gcc.gnu.org>
Mon, 12 Oct 2020 07:56:13 +0000 (08:56 +0100)
Only check for kind if the type supports kind.

2020-10-12  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/fortran/ChangeLog:

PR fortran/96099
* decl.c (gfc_match_implicit): Check for numeric and logical
types.

2020-10-12  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/ChangeLog:

PR fortran/96099
* gfortran.dg/pr96099_1.f90: New test.
* gfortran.dg/pr96099_2.f90: New test.

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

index 326e6f5db7aeed29ab44a80de61a5f4ce466ac27..bddf69cce19830dff781a225579638b633e09153 100644 (file)
@@ -4835,7 +4835,7 @@ gfc_match_implicit (void)
       /* Last chance -- check <TYPE> <SELECTOR> (<RANGE>).  */
       if (ts.type == BT_CHARACTER)
        m = gfc_match_char_spec (&ts);
-      else if (ts.type != BT_DERIVED)
+      else if (gfc_numeric_ts(&ts) || ts.type == BT_LOGICAL)
        {
          m = gfc_match_kind_spec (&ts, false);
          if (m == MATCH_NO)
diff --git a/gcc/testsuite/gfortran.dg/pr96099_1.f90 b/gcc/testsuite/gfortran.dg/pr96099_1.f90
new file mode 100644 (file)
index 0000000..9754bd3
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+
+program pr96099_1
+   implicit class(t) (1) ! { dg-error "Syntax error in IMPLICIT" }
+   type t
+   end type
+end
+
diff --git a/gcc/testsuite/gfortran.dg/pr96099_2.f90 b/gcc/testsuite/gfortran.dg/pr96099_2.f90
new file mode 100644 (file)
index 0000000..3136d2e
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+
+program pr96099_2
+   integer n1
+   parameter (n1 = 1)
+   implicit class(t) (n1) ! { dg-error "Syntax error in IMPLICIT" }
+   type t
+   end type
+end