From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH,fortran/32942] Give EXPONENT the correct return type
Date: Tue, 31 Jul 2007 20:52:00 -0000 [thread overview]
Message-ID: <20070731203157.GA30019@troutmask.apl.washington.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
The library routines for EXPONENT return a INTEGER(4) value.
When -fdefault-integer-8 is used, the result needs to be
convert to the correct type. The attach patch, regression
tested on amd64-*-freebsd, does the trick.
OK for trunk?
2007-07-31 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/32942
* gfortran.dg/exponent_2.f90: New test.
2007-07-31 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/32942
*trans-intrinsic.c (gfc_conv_intrinsic_exponent): Convert to correct
type.
--
Steve
[-- Attachment #2: pr32942.diff --]
[-- Type: text/x-diff, Size: 1421 bytes --]
Index: testsuite/gfortran.dg/exponent_2.f90
===================================================================
--- testsuite/gfortran.dg/exponent_2.f90 (revision 0)
+++ testsuite/gfortran.dg/exponent_2.f90 (revision 0)
@@ -0,0 +1,11 @@
+! { dg-do run }
+! { dg-options "-fdefault-integer-8" }
+! PR fortran/32942
+! Testcase contributed by Dominique d'Humieres <dominiq@lps.ens.fr>.
+integer i
+real x
+x = 3.0
+if (2 /= exponent(x)) call abort
+i = exponent (x)
+if (i /= 2) call abort
+end
Index: fortran/trans-intrinsic.c
===================================================================
--- fortran/trans-intrinsic.c (revision 127065)
+++ fortran/trans-intrinsic.c (working copy)
@@ -718,9 +718,9 @@ gfc_conv_intrinsic_lib_function (gfc_se
/* Generate code for EXPONENT(X) intrinsic function. */
static void
-gfc_conv_intrinsic_exponent (gfc_se * se, gfc_expr * expr)
+gfc_conv_intrinsic_exponent (gfc_se *se, gfc_expr *expr)
{
- tree arg, fndecl;
+ tree arg, fndecl, type;
gfc_expr *a1;
gfc_conv_intrinsic_function_args (se, expr, &arg, 1);
@@ -744,7 +744,9 @@ gfc_conv_intrinsic_exponent (gfc_se * se
gcc_unreachable ();
}
- se->expr = build_call_expr (fndecl, 1, arg);
+ /* Convert it to the required type. */
+ type = gfc_typenode_for_spec (&expr->ts);
+ se->expr = fold_convert (type, build_call_expr (fndecl, 1, arg));
}
/* Evaluate a single upper or lower bound. */
next reply other threads:[~2007-07-31 20:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-31 20:52 Steve Kargl [this message]
2007-07-31 21:25 ` FX Coudert
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=20070731203157.GA30019@troutmask.apl.washington.edu \
--to=sgk@troutmask.apl.washington.edu \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@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).