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-3309] Fortran: fix check of polymorphic elements in data transfers [PR100971] Date: Fri, 14 Oct 2022 20:17:56 +0000 (GMT) [thread overview] Message-ID: <20221014201756.491463858D38@sourceware.org> (raw) https://gcc.gnu.org/g:89f20c9ae4641f9b2e87e47f7dab3dc197faa0aa commit r13-3309-g89f20c9ae4641f9b2e87e47f7dab3dc197faa0aa Author: Harald Anlauf <anlauf@gmx.de> Date: Sun Oct 9 20:43:32 2022 +0200 Fortran: fix check of polymorphic elements in data transfers [PR100971] gcc/fortran/ChangeLog: PR fortran/100971 * resolve.cc (resolve_transfer): Extend check for permissibility of polymorphic elements in a data transfer to arrays. gcc/testsuite/ChangeLog: PR fortran/100971 * gfortran.dg/der_io_5.f90: New test. Diff: --- gcc/fortran/resolve.cc | 5 +++++ gcc/testsuite/gfortran.dg/der_io_5.f90 | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index d133bc2d034..9202e2f10ad 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -10017,6 +10017,7 @@ resolve_transfer (gfc_code *code) if (exp == NULL || (exp->expr_type != EXPR_VARIABLE && exp->expr_type != EXPR_FUNCTION + && exp->expr_type != EXPR_ARRAY && exp->expr_type != EXPR_STRUCTURE)) return; @@ -10030,6 +10031,7 @@ resolve_transfer (gfc_code *code) const gfc_typespec *ts = exp->expr_type == EXPR_STRUCTURE || exp->expr_type == EXPR_FUNCTION + || exp->expr_type == EXPR_ARRAY ? &exp->ts : &exp->symtree->n.sym->ts; /* Go to actual component transferred. */ @@ -10128,6 +10130,9 @@ resolve_transfer (gfc_code *code) if (exp->expr_type == EXPR_STRUCTURE) return; + if (exp->expr_type == EXPR_ARRAY) + return; + sym = exp->symtree->n.sym; if (sym->as != NULL && sym->as->type == AS_ASSUMED_SIZE && exp->ref diff --git a/gcc/testsuite/gfortran.dg/der_io_5.f90 b/gcc/testsuite/gfortran.dg/der_io_5.f90 new file mode 100644 index 00000000000..193916c4a65 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/der_io_5.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } +! PR fortran/100971 - ICE: Bad IO basetype (7) +! Contributed by G.Steinmetz + +program p + implicit none + type t + end type + class(t), allocatable :: a, b(:) + type(t) :: x, y(1) + integer :: i + allocate (a,b(1)) + print *, [a] ! { dg-error "Data transfer element at .1. cannot be polymorphic" } + print *, [(b(i),i=1,1)] ! { dg-error "Data transfer element at .1. cannot be polymorphic" } + print *, [x] + print *, [(y(i),i=1,1)] +end
reply other threads:[~2022-10-14 20:17 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=20221014201756.491463858D38@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).