aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/parse.cc2
-rw-r--r--gcc/testsuite/gfortran.dg/pr107423.f9018
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index cdae43f..bc2b218 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -4015,7 +4015,7 @@ parse_spec (gfc_statement st)
gfc_symbol* proc = gfc_current_ns->proc_name;
gcc_assert (proc);
- if (proc->result->ts.type == BT_UNKNOWN)
+ if (proc->result && proc->result->ts.type == BT_UNKNOWN)
function_result_typed = true;
}
diff --git a/gcc/testsuite/gfortran.dg/pr107423.f90 b/gcc/testsuite/gfortran.dg/pr107423.f90
new file mode 100644
index 0000000..9ae64c9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107423.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+! PR fortran/107423 - ICE in parse_spec
+! Contributed by G.Steinmetz
+
+program p
+ type t(k)
+ integer, kind :: k ! { dg-error "Fortran 2003" }
+ integer :: a
+ end type
+contains
+ function f()
+ type(t(4)), allocatable :: x ! { dg-error "Invalid character" }
+ allocate (t(4) :: x) ! { dg-error "cannot be used" }
+ end ! { dg-error "END" }
+end ! { dg-error "END" }
+
+! { dg-prune-output "Unexpected end of file" }