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-4107] Fortran: error recovery after reference to bad CLASS variable [PR107681] Date: Wed, 16 Nov 2022 20:45:08 +0000 (GMT) [thread overview] Message-ID: <20221116204508.CED2E396D823@sourceware.org> (raw) https://gcc.gnu.org/g:96e4244ef3ccf4867ca4e37fbc6800e64ef30af6 commit r13-4107-g96e4244ef3ccf4867ca4e37fbc6800e64ef30af6 Author: Harald Anlauf <anlauf@gmx.de> Date: Wed Nov 16 21:41:19 2022 +0100 Fortran: error recovery after reference to bad CLASS variable [PR107681] gcc/fortran/ChangeLog: PR fortran/107681 * resolve.cc (resolve_fl_var_and_proc): Prevent NULL pointer dereference with reference to bad CLASS variable. gcc/testsuite/ChangeLog: PR fortran/107681 * gfortran.dg/pr107681.f90: New test. Diff: --- gcc/fortran/resolve.cc | 1 + gcc/testsuite/gfortran.dg/pr107681.f90 | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 5ff1cd070ac..24e5aa03556 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -12967,6 +12967,7 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) && sym->ts.u.derived && !sym->attr.select_type_temporary && !UNLIMITED_POLY (sym) + && CLASS_DATA (sym)->ts.u.derived && !gfc_type_is_extensible (CLASS_DATA (sym)->ts.u.derived)) { gfc_error ("Type %qs of CLASS variable %qs at %L is not extensible", diff --git a/gcc/testsuite/gfortran.dg/pr107681.f90 b/gcc/testsuite/gfortran.dg/pr107681.f90 new file mode 100644 index 00000000000..0999ad92649 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107681.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } +! PR fortran/107681 - ICE in gfc_type_is_extensible +! Contributed by G.Steinmetz + +program p + type t + integer, allocatable :: a + end type + class(t) :: x[*] ! { dg-error "must be dummy, allocatable or pointer" } + associate (y => x) ! { dg-error "Invalid array reference" } + end associate +end
reply other threads:[~2022-11-16 20:45 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=20221116204508.CED2E396D823@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).