public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fortran/67525 -- fix ICE in SELECT TYPE
@ 2015-09-25 19:23 Steve Kargl
  2015-09-25 20:39 ` Jerry DeLisle
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2015-09-25 19:23 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]

The follwoing patch has been built and regression 
tested on x86_64-*-freebsd.  There were no regression.

The patch removes an assert, which allows gfortran
to detect an invalid selector in SELECT TYPE statement.

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.

-- 
Steve

[-- Attachment #2: pr67525.diff --]
[-- Type: text/x-diff, Size: 1649 bytes --]

Index: fortran/parse.c
===================================================================
--- fortran/parse.c	(revision 228061)
+++ fortran/parse.c	(working copy)
@@ -3113,15 +3113,18 @@ match_deferred_characteristics (gfc_type
 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: testsuite/gfortran.dg/pr67525.f90
===================================================================
--- testsuite/gfortran.dg/pr67525.f90	(revision 0)
+++ testsuite/gfortran.dg/pr67525.f90	(working copy)
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fortran/67525 -- fix ICE in SELECT TYPE
  2015-09-25 19:23 [PATCH] fortran/67525 -- fix ICE in SELECT TYPE Steve Kargl
@ 2015-09-25 20:39 ` Jerry DeLisle
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2015-09-25 20:39 UTC (permalink / raw)
  To: Steve Kargl, fortran, gcc-patches

On 09/25/2015 12:13 PM, Steve Kargl wrote:
> The follwoing patch has been built and regression 
> tested on x86_64-*-freebsd.  There were no regression.
> 
> The patch removes an assert, which allows gfortran
> to detect an invalid selector in SELECT TYPE statement.
> 
OK, thanks for patch!

Jerry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-25 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-25 19:23 [PATCH] fortran/67525 -- fix ICE in SELECT TYPE Steve Kargl
2015-09-25 20:39 ` Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).