+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>
PR fortran/83149
/* 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,
--- /dev/null
+! { 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