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-9923] Fortran: fix ICE overloading elemental intrinsics Date: Sun, 23 Jan 2022 21:53:23 +0000 (GMT) [thread overview] Message-ID: <20220123215323.A172B3858D28@sourceware.org> (raw) https://gcc.gnu.org/g:7fecbf36d174c8005e8c5cfb7089c6bd4d0f6a79 commit r9-9923-g7fecbf36d174c8005e8c5cfb7089c6bd4d0f6a79 Author: Harald Anlauf <anlauf@gmx.de> Date: Thu Jan 13 21:50:45 2022 +0100 Fortran: fix ICE overloading elemental intrinsics gcc/fortran/ChangeLog: PR fortran/103782 * expr.c (gfc_simplify_expr): Adjust logic for when to scalarize a call of an intrinsic which may have been overloaded. gcc/testsuite/ChangeLog: PR fortran/103782 * gfortran.dg/overload_4.f90: New test. (cherry picked from commit a4a8ae123cd70188e4b4bf5e288a84e0a76fb0fd) Diff: --- gcc/fortran/expr.c | 5 ++--- gcc/testsuite/gfortran.dg/overload_4.f90 | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index f099da98ab0..7b61488bfe9 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2143,10 +2143,9 @@ gfc_simplify_expr (gfc_expr *p, int type) && gfc_intrinsic_func_interface (p, 1) == MATCH_ERROR) return false; - if (p->expr_type == EXPR_FUNCTION) + if (p->symtree && (p->value.function.isym || p->ts.type == BT_UNKNOWN)) { - if (p->symtree) - isym = gfc_find_function (p->symtree->n.sym->name); + isym = gfc_find_function (p->symtree->n.sym->name); if (isym && isym->elemental) scalarize_intrinsic_call (p, false); } diff --git a/gcc/testsuite/gfortran.dg/overload_4.f90 b/gcc/testsuite/gfortran.dg/overload_4.f90 new file mode 100644 index 00000000000..43207e358ba --- /dev/null +++ b/gcc/testsuite/gfortran.dg/overload_4.f90 @@ -0,0 +1,27 @@ +! { dg-do run } +! { dg-additional-options "-Wno-intrinsic-shadow" } +! PR fortran/103782 - ICE overloading an intrinsic like dble or real +! Contributed by Urban Jost + +program runtest + implicit none + interface dble + procedure to_double + end interface dble + interface real + procedure floor ! not really FLOOR... + end interface real + if (any (dble ([10.0d0,20.0d0]) - [10.0d0,20.0d0] /= 0.d0)) stop 1 + if (any (real ([1.5,2.5]) - [1.5,2.5] /= 0.0 )) stop 2 +contains + elemental function to_double (valuein) result(d_out) + doubleprecision,intent(in) :: valuein + doubleprecision :: d_out + d_out=valuein + end function to_double + elemental function floor (valuein) result(d_out) ! not really FLOOR... + real, intent(in) :: valuein + real :: d_out + d_out=valuein + end function floor +end program runtest
reply other threads:[~2022-01-23 21:53 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=20220123215323.A172B3858D28@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).