* [PATCH, fortran] Convert returned types to correct type.
@ 2007-08-02 20:17 Steve Kargl
2007-08-03 14:33 ` FX Coudert
0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2007-08-02 20:17 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
:ADDPATCH:
Here's is another patch that fixes a problem exposed by
-fdefault-integer-8. The return type of the selected_*_kind
function was int4 but needs to be converted to int8.
I've tested the patch on both i386 and amd64-*-freebsd.
2007-08-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/32968
* gfortran.dg/selected_kind_1.f90: New test.
2007-08-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/32968
* trans-intrinsic.c(gfc_conv_intrinsic_si_kind,
gfc_conv_intrinsic_sr_kind): Convert to the correct type.
--
Steve
[-- Attachment #2: selected.diff --]
[-- Type: text/x-diff, Size: 2103 bytes --]
Index: gcc/testsuite/gfortran.dg/selected_kind_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/selected_kind_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/selected_kind_1.f90 (revision 0)
@@ -0,0 +1,16 @@
+! { dg-do run }
+! { dg-options "-fdefault-integer-8" }
+! PR fortran/32968
+program selected
+
+ if (selected_int_kind (1) /= 1) call abort
+ if (selected_int_kind (3) /= 2) call abort
+ if (selected_int_kind (5) /= 4) call abort
+ if (selected_int_kind (10) /= 8) call abort
+ if (selected_real_kind (1) /= 4) call abort
+ if (selected_real_kind (2) /= 4) call abort
+ if (selected_real_kind (9) /= 8) call abort
+ if (selected_real_kind (10) /= 8) call abort
+
+end program selected
+
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (revision 127167)
+++ gcc/fortran/trans-intrinsic.c (working copy)
@@ -3467,11 +3467,15 @@ gfc_conv_intrinsic_verify (gfc_se * se,
static void
gfc_conv_intrinsic_si_kind (gfc_se * se, gfc_expr * expr)
{
- tree arg;
+ tree arg, type;
gfc_conv_intrinsic_function_args (se, expr, &arg, 1);
arg = build_fold_addr_expr (arg);
+
+ /* Convert it to the required type. */
+ type = gfc_typenode_for_spec (&expr->ts);
se->expr = build_call_expr (gfor_fndecl_si_kind, 1, arg);
+ se->expr = fold_convert (type, se->expr);
}
/* Generate code for SELECTED_REAL_KIND (P, R) intrinsic function. */
@@ -3480,7 +3484,7 @@ static void
gfc_conv_intrinsic_sr_kind (gfc_se * se, gfc_expr * expr)
{
gfc_actual_arglist *actual;
- tree args;
+ tree args, type;
gfc_se argse;
args = NULL_TREE;
@@ -3498,7 +3502,11 @@ gfc_conv_intrinsic_sr_kind (gfc_se * se,
gfc_add_block_to_block (&se->post, &argse.post);
args = gfc_chainon_list (args, argse.expr);
}
+
+ /* Convert it to the required type. */
+ type = gfc_typenode_for_spec (&expr->ts);
se->expr = build_function_call_expr (gfor_fndecl_sr_kind, args);
+ se->expr = fold_convert (type, se->expr);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, fortran] Convert returned types to correct type.
2007-08-02 20:17 [PATCH, fortran] Convert returned types to correct type Steve Kargl
@ 2007-08-03 14:33 ` FX Coudert
0 siblings, 0 replies; 2+ messages in thread
From: FX Coudert @ 2007-08-03 14:33 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches
> 2007-08-02 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/32968
> * trans-intrinsic.c(gfc_conv_intrinsic_si_kind,
> gfc_conv_intrinsic_sr_kind): Convert to the correct type.
OK
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-03 14:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-02 20:17 [PATCH, fortran] Convert returned types to correct type Steve Kargl
2007-08-03 14:33 ` FX Coudert
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).