* [patch, fortran] Bug 84506 - [6/7/8 Regression]INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8
@ 2018-02-23 16:27 Jerry DeLisle
2018-02-23 17:33 ` Steve Kargl
0 siblings, 1 reply; 2+ messages in thread
From: Jerry DeLisle @ 2018-02-23 16:27 UTC (permalink / raw)
To: fortran; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 719 bytes --]
Hi Folks,
This bug is a result of a range check we do on kind=8 unit numbers to
make sure they fall within the range values of a kind=4 integer. We were
limiting this range to positive values. I think when we introduced the
newunit feature which uses negative unit values, we missed this adjustment.
The attached patch is trivial. Regression tested on x86_86-pc-linux-gnu.
I will back port to 6 an 7 after approval here. I will use the case in
the PR as a new test case.
OK for trunk?
Regards,
Jerry
2018-02-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/84506
* trans-io.c (set_parameter_value_inquire): Adjust range check of
negative unit values for kind=8 units to the kind=4 negative limit.
[-- Attachment #2: pr84506.diff --]
[-- Type: text/x-patch, Size: 996 bytes --]
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index 021c788ba54..36adb034475 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -639,12 +639,12 @@ set_parameter_value_inquire (stmtblock_t *block, tree var,
/* Don't evaluate the UNIT number multiple times. */
se.expr = gfc_evaluate_now (se.expr, &se.pre);
- /* UNIT numbers should be greater than zero. */
+ /* UNIT numbers should be greater than the min. */
i = gfc_validate_kind (BT_INTEGER, 4, false);
+ val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].pedantic_min_int, 4);
cond1 = build2_loc (input_location, LT_EXPR, logical_type_node,
se.expr,
- fold_convert (TREE_TYPE (se.expr),
- integer_zero_node));
+ fold_convert (TREE_TYPE (se.expr), val));
/* UNIT numbers should be less than the max. */
val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4);
cond2 = build2_loc (input_location, GT_EXPR, logical_type_node,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch, fortran] Bug 84506 - [6/7/8 Regression]INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8
2018-02-23 16:27 [patch, fortran] Bug 84506 - [6/7/8 Regression]INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8 Jerry DeLisle
@ 2018-02-23 17:33 ` Steve Kargl
0 siblings, 0 replies; 2+ messages in thread
From: Steve Kargl @ 2018-02-23 17:33 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: fortran, GCC Patches
On Fri, Feb 23, 2018 at 08:27:18AM -0800, Jerry DeLisle wrote:
>
> I will back port to 6 an 7 after approval here. I will use the case in
> the PR as a new test case.
>
> OK for trunk?
>
> Regards,
>
> Jerry
>
> 2018-02-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
> PR fortran/84506
> * trans-io.c (set_parameter_value_inquire): Adjust range check of
> negative unit values for kind=8 units to the kind=4 negative limit.
OK (with a testcase :-)
--
Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-23 17:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 16:27 [patch, fortran] Bug 84506 - [6/7/8 Regression]INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8 Jerry DeLisle
2018-02-23 17:33 ` Steve Kargl
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).