mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 01:40:39 +08:00
Fortran: NULL pointer dereference while parsing a function [PR107423]
gcc/fortran/ChangeLog: PR fortran/107423 * parse.cc (parse_spec): Avoid NULL pointer dereference when parsing a function and an error occured. gcc/testsuite/ChangeLog: PR fortran/107423 * gfortran.dg/pr107423.f90: New test.
This commit is contained in:
parent
69ec1e2065
commit
531ca06c00
@ -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;
|
||||
}
|
||||
|
||||
|
18
gcc/testsuite/gfortran.dg/pr107423.f90
Normal file
18
gcc/testsuite/gfortran.dg/pr107423.f90
Normal file
@ -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" }
|
Loading…
x
Reference in New Issue
Block a user