re PR fortran/66245 (ICE on select type with empty type spec)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 8 Jun 2015 15:55:16 +0000 (15:55 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 8 Jun 2015 15:55:16 +0000 (15:55 +0000)
2015-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/66245
* match.c (gfc_match_type_is, gfc_match_class_is):  Check if the
return type spec or derived type spec is validate.

2015-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/66245
* gfortran.dg/class_is_1.f90: New test.
* gfortran.dg/type_is_1.f90: Ditto.

From-SVN: r224237

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_is_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/type_is_1.f90 [new file with mode: 0644]

index 7d3e31e0a02984814c7c2a28fa6acde95cd9f4b1..cf42e384e07363bd04dd5bb1ba7c2a46af8009b4 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/66245
+       * match.c (gfc_match_type_is, gfc_match_class_is):  Check if the
+       return type spec or derived type spec is validate.
+
 2015-06-06  Thomas Koenig  <tkoenig@netcologne.de>
 
        PR fortran/47659
index b51d18a29250435673d41818bba1fd204bbd4a9b..c064135bcabd0297a29d35f033f343e884fa8dd2 100644 (file)
@@ -5456,7 +5456,10 @@ gfc_match_type_is (void)
   c = gfc_get_case ();
   c->where = gfc_current_locus;
 
-  if (gfc_match_type_spec (&c->ts) == MATCH_ERROR)
+  m = gfc_match_type_spec (&c->ts);
+  if (m == MATCH_NO)
+    goto syntax;
+  if (m == MATCH_ERROR)
     goto cleanup;
 
   if (gfc_match_char (')') != MATCH_YES)
@@ -5536,7 +5539,10 @@ gfc_match_class_is (void)
   c = gfc_get_case ();
   c->where = gfc_current_locus;
 
-  if (match_derived_type_spec (&c->ts) == MATCH_ERROR)
+  m = match_derived_type_spec (&c->ts);
+  if (m == MATCH_NO)
+    goto syntax;
+  if (m == MATCH_ERROR)
     goto cleanup;
 
   if (c->ts.type == BT_DERIVED)
index 202551f2161250596557278420b8b8e5999a235a..ffef82e3ff2704590614e3ee98b0fc94916c9842 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-08  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/66245
+       * gfortran.dg/class_is_1.f90: New test.
+       * gfortran.dg/type_is_1.f90: Ditto.
+
 2015-06-08  Marek Polacek  <polacek@redhat.com>
 
        PR c/66415
diff --git a/gcc/testsuite/gfortran.dg/class_is_1.f90 b/gcc/testsuite/gfortran.dg/class_is_1.f90
new file mode 100644 (file)
index 0000000..b5bc5a9
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! PR fortran/66245
+! Original testcase by Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+program p
+   type t; end type
+   class(t), allocatable :: x
+   call s
+   contains
+      subroutine s
+         select type ( x )
+         class is ( )       ! { dg-error "error in CLASS IS" }
+         end select
+      end subroutine s
+end program p
diff --git a/gcc/testsuite/gfortran.dg/type_is_1.f90 b/gcc/testsuite/gfortran.dg/type_is_1.f90
new file mode 100644 (file)
index 0000000..860a668
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! PR fortran/66245
+! Original testcase by Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+program p
+   type t; end type
+   class(t), allocatable :: x
+   call s
+   contains
+      subroutine s
+         select type ( x )
+         type is ( )       ! { dg-error "error in TYPE IS" }
+         end select
+      end subroutine s
+end program p