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 r12-1650] Fortran - fix conversion to result type for the min/max intrinsic
Date: Fri, 18 Jun 2021 17:34:37 +0000 (GMT)	[thread overview]
Message-ID: <20210618173437.6143B3839C45@sourceware.org> (raw)

https://gcc.gnu.org/g:6fc543396345900f460c9fa7121239cb1ebbc3a3

commit r12-1650-g6fc543396345900f460c9fa7121239cb1ebbc3a3
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Jun 18 19:34:15 2021 +0200

    Fortran - fix conversion to result type for the min/max intrinsic
    
    gcc/fortran/ChangeLog:
    
            PR fortran/100283
            PR fortran/101123
            * trans-intrinsic.c (gfc_conv_intrinsic_minmax): Unconditionally
            convert result of min/max to result type.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/100283
            PR fortran/101123
            * gfortran.dg/min0_max0_1.f90: New test.
            * gfortran.dg/min0_max0_2.f90: New test.

Diff:
---
 gcc/fortran/trans-intrinsic.c             |  5 +----
 gcc/testsuite/gfortran.dg/min0_max0_1.f90 |  9 +++++++++
 gcc/testsuite/gfortran.dg/min0_max0_2.f90 | 10 ++++++++++
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 73b0bcc9dea..e578449995a 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -4147,10 +4147,7 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op)
 			build_empty_stmt (input_location));
       gfc_add_expr_to_block (&se->pre, tmp);
     }
-  if (TREE_CODE (type) == INTEGER_TYPE)
-    se->expr = fold_build1_loc (input_location, FIX_TRUNC_EXPR, type, mvar);
-  else
-    se->expr = convert (type, mvar);
+  se->expr = convert (type, mvar);
 }
 
 
diff --git a/gcc/testsuite/gfortran.dg/min0_max0_1.f90 b/gcc/testsuite/gfortran.dg/min0_max0_1.f90
new file mode 100644
index 00000000000..118b0f03b52
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/min0_max0_1.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-std=gnu" }
+! PR fortran/100283
+
+subroutine s ()
+  integer(kind=8) :: i,j,k
+  i = min0 (j,k)
+  i = max0 (-127_8, min0 (j,127_8))
+end subroutine s
diff --git a/gcc/testsuite/gfortran.dg/min0_max0_2.f90 b/gcc/testsuite/gfortran.dg/min0_max0_2.f90
new file mode 100644
index 00000000000..3fe4fcd3609
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/min0_max0_2.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-fdefault-integer-8 -std=gnu" }
+! PR fortran/101123
+
+SUBROUTINE TEST
+  IMPLICIT INTEGER*4 (I-N)
+  MAXMN=MAX0(M,N)
+  MINMN=MIN0(M,0_4)
+  MAXRS=MAX1(R,S)
+END SUBROUTINE TEST


                 reply	other threads:[~2021-06-18 17:34 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=20210618173437.6143B3839C45@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: link
Be 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).