Commit 55ebc31f by Jerry DeLisle

re PR fortran/84506 (INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8)

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.

	* gfortran.dg/inquire_19.f90: New test.

From-SVN: r257941
parent 59b2c134
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.
2018-02-23 Paul Thomas <pault@gcc.gnu.org> 2018-02-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/83149 PR fortran/83149
......
...@@ -639,12 +639,12 @@ set_parameter_value_inquire (stmtblock_t *block, tree var, ...@@ -639,12 +639,12 @@ set_parameter_value_inquire (stmtblock_t *block, tree var,
/* Don't evaluate the UNIT number multiple times. */ /* Don't evaluate the UNIT number multiple times. */
se.expr = gfc_evaluate_now (se.expr, &se.pre); 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); 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, cond1 = build2_loc (input_location, LT_EXPR, logical_type_node,
se.expr, se.expr,
fold_convert (TREE_TYPE (se.expr), fold_convert (TREE_TYPE (se.expr), val));
integer_zero_node));
/* UNIT numbers should be less than the max. */ /* UNIT numbers should be less than the max. */
val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4); val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4);
cond2 = build2_loc (input_location, GT_EXPR, logical_type_node, cond2 = build2_loc (input_location, GT_EXPR, logical_type_node,
......
2018-02-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/84506
* gfortran.dg/inquire_19.f90: New test.
2018-02-23 Paul Thomas <pault@gcc.gnu.org> 2018-02-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/83149 PR fortran/83149
......
! { dg-do run }
! PR84506 INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8
program TestInquire
implicit none
integer(8) :: iUnit
integer(8) :: iPos
open(newunit=iunit, file='output.txt', access='stream', status='replace')
write(iUnit) 'TEXT'
inquire(iUnit, pos=iPos)
close(iUnit, status='delete')
!print *, iPos
if (iPos.ne.5) stop 1
end program TestInquire
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment