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 r9-9719] Fortran: Fix ICE due to elemental procedure pointers [PR98472]. Date: Fri, 10 Sep 2021 19:57:38 +0000 (GMT) [thread overview] Message-ID: <20210910195738.9FDA63858D29@sourceware.org> (raw) https://gcc.gnu.org/g:c101105e7852a940f967137f6b9e0a97d7f2c3c3 commit r9-9719-gc101105e7852a940f967137f6b9e0a97d7f2c3c3 Author: Paul Thomas <pault@gcc.gnu.org> Date: Wed Jan 27 09:12:16 2021 +0000 Fortran: Fix ICE due to elemental procedure pointers [PR98472]. 2021-01-27 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/98472 * trans-array.c (gfc_conv_expr_descriptor): Include elemental procedure pointers in the assert under the comment 'elemental function' and eliminate the second, spurious assert. gcc/testsuite/ PR fortran/98472 * gfortran.dg/elemental_function_5.f90 : New test. (cherry picked from commit 003f0414291d595d2126e6d2e24b281f38f3448f) Diff: --- gcc/fortran/trans-array.c | 4 +- gcc/testsuite/gfortran.dg/elemental_function_5.f90 | 46 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 7b45c58c4b4..d6315624f2c 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -7529,9 +7529,9 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) && expr->value.function.esym->attr.elemental) || (expr->value.function.isym != NULL && expr->value.function.isym->elemental) + || (gfc_expr_attr (expr).proc_pointer + && gfc_expr_attr (expr).elemental) || gfc_inline_intrinsic_function_p (expr)); - else - gcc_assert (ss_type == GFC_SS_INTRINSIC); need_tmp = 1; if (expr->ts.type == BT_CHARACTER diff --git a/gcc/testsuite/gfortran.dg/elemental_function_5.f90 b/gcc/testsuite/gfortran.dg/elemental_function_5.f90 new file mode 100644 index 00000000000..315ff9162b3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/elemental_function_5.f90 @@ -0,0 +1,46 @@ +! { dg-do compile } +! +! Test the fix for PR98472. +! +! Contributed by Rui Coelho <ruicoelhopedro@hotmail.com> +! +module a + type, abstract :: base + contains + procedure(elem_func), deferred, nopass :: add + end type base + + type, extends(base) :: derived + contains + procedure, nopass :: add => add_derived + end type derived + + abstract interface + elemental function elem_func(x, y) result(out) + integer, intent(in) :: x, y + integer :: out + end function elem_func + end interface + +contains + elemental function add_derived(x, y) result(out) + integer, intent(in) :: x, y + integer :: out + out = x + y + end function add_derived +end module a + +program main + use a + call foo +contains + subroutine foo + integer, dimension(:), allocatable :: vec + class(base), allocatable :: instance + allocate(derived :: instance) + allocate(vec, source=instance%add([1, 2], [1, 2])) ! ICE here + if (any (vec .ne. [2, 4])) stop 1 + end +end program main + +
reply other threads:[~2021-09-10 19:57 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=20210910195738.9FDA63858D29@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).