re PR fortran/67525 (ICE on select type with improper selector)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 25 Sep 2015 22:28:04 +0000 (22:28 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 25 Sep 2015 22:28:04 +0000 (22:28 +0000)
2015-09-25  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/67525
* parse.c (match_deferred_characteristics): Remove an assert, which
allows an invalid SELECT TYPE selector to be detected.

2015-09-25  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/67525
* gfortran.dg/pr67525.f90: New test.

From-SVN: r228155

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

index 8e33a1d..1e3a7a1 100644 (file)
@@ -1,3 +1,9 @@
+2015-09-25  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/67525
+       * parse.c (match_deferred_characteristics): Remove an assert, which
+       allows an invalid SELECT TYPE selector to be detected.
+
 2015-09-25  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR pretty-print/67567
index 62bcb61..f8d84de 100644 (file)
@@ -3113,15 +3113,18 @@ match_deferred_characteristics (gfc_typespec * ts)
 static void
 check_function_result_typed (void)
 {
-  gfc_typespec* ts = &gfc_current_ns->proc_name->result->ts;
+  gfc_typespec ts;
 
   gcc_assert (gfc_current_state () == COMP_FUNCTION);
-  gcc_assert (ts->type != BT_UNKNOWN);
+
+  if (!gfc_current_ns->proc_name->result) return;
+
+  ts = gfc_current_ns->proc_name->result->ts;
 
   /* Check type-parameters, at the moment only CHARACTER lengths possible.  */
   /* TODO:  Extend when KIND type parameters are implemented.  */
-  if (ts->type == BT_CHARACTER && ts->u.cl && ts->u.cl->length)
-    gfc_expr_check_typed (ts->u.cl->length, gfc_current_ns, true);
+  if (ts.type == BT_CHARACTER && ts.u.cl && ts.u.cl->length)
+    gfc_expr_check_typed (ts.u.cl->length, gfc_current_ns, true);
 }
 
 
index 248f933..a98e701 100644 (file)
@@ -1,3 +1,8 @@
+2015-09-25  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/67525
+       * gfortran.dg/pr67525.f90: New test.
+
 2015-09-25  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/55603
diff --git a/gcc/testsuite/gfortran.dg/pr67525.f90 b/gcc/testsuite/gfortran.dg/pr67525.f90
new file mode 100644 (file)
index 0000000..35f716d
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! PR fortran/67525
+! Code contributed by Gerhard Steinmetz
+!
+real function f(x)
+   select type (x)         ! { dg-error "shall be polymorphic" }
+   end select
+end function f
+
+real function g(x)
+   select type (x=>null()) ! { dg-error "shall be polymorphic" }
+   end select
+end function g
+
+subroutine a(x)
+   select type (x)         ! { dg-error "shall be polymorphic" }
+   end select
+end subroutine a