public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4681] Fortran: NULL pointer dereference while parsing a function [PR107423] Date: Tue, 13 Dec 2022 18:09:10 +0000 (GMT) [thread overview] Message-ID: <20221213180910.930CC383AB6E@sourceware.org> (raw) https://gcc.gnu.org/g:531ca06c007d4c4d156637083dcad7f25ac8713d commit r13-4681-g531ca06c007d4c4d156637083dcad7f25ac8713d Author: Steve Kargl <kargl@gcc.gnu.org> Date: Mon Dec 12 21:11:07 2022 +0100 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. Diff: --- gcc/fortran/parse.cc | 2 +- gcc/testsuite/gfortran.dg/pr107423.f90 | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index cdae43fa1fd..bc2b2188eea 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 00000000000..9ae64c94ae0 --- /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" }
reply other threads:[~2022-12-13 18:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221213180910.930CC383AB6E@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).