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 r10-10344] Fortran: fix checking of elemental functions of type CLASS Date: Thu, 16 Dec 2021 22:22:53 +0000 (GMT) [thread overview] Message-ID: <20211216222253.A587A385840B@sourceware.org> (raw) https://gcc.gnu.org/g:b0b1b21c561a0fe5f334a16662cd27f923842bf6 commit r10-10344-gb0b1b21c561a0fe5f334a16662cd27f923842bf6 Author: Harald Anlauf <anlauf@gmx.de> Date: Fri Dec 10 22:41:24 2021 +0100 Fortran: fix checking of elemental functions of type CLASS gcc/fortran/ChangeLog: PR fortran/103606 * resolve.c (resolve_fl_procedure): Do not access CLASS components before class container has been built. gcc/testsuite/ChangeLog: PR fortran/103606 * gfortran.dg/pr103606.f90: New test. (cherry picked from commit 7e913caad081ea85da4f257265f2d3383cdbe8d5) Diff: --- gcc/fortran/resolve.c | 3 ++- gcc/testsuite/gfortran.dg/pr103606.f90 | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 0489184302c..591b36fa4bd 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -13140,7 +13140,8 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) /* An elemental function is required to return a scalar 12.7.1 */ if (sym->attr.elemental && sym->attr.function - && (sym->as || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as))) + && (sym->as || (sym->ts.type == BT_CLASS && sym->attr.class_ok + && CLASS_DATA (sym)->as))) { gfc_error ("ELEMENTAL function %qs at %L must have a scalar " "result", sym->name, &sym->declared_at); diff --git a/gcc/testsuite/gfortran.dg/pr103606.f90 b/gcc/testsuite/gfortran.dg/pr103606.f90 new file mode 100644 index 00000000000..43283184e89 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103606.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! PR fortran/103606 - ICE in resolve_fl_procedure +! Contributed by G.Steinmetz + +program p + type t + end type +contains + elemental function f() result(z) ! { dg-error "CLASS variable" } + class(t) :: z + end +end
reply other threads:[~2021-12-16 22:22 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=20211216222253.A587A385840B@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).