From: Jerry DeLisle Date: Fri, 23 Feb 2018 18:40:14 +0000 (+0000) Subject: re PR fortran/84506 (INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=55ebc31f3d521e66059e6f83b9884a0ae8d941ab;p=gcc.git re PR fortran/84506 (INQUIRE(pos=) always sets pos=0 with -fdefault-integer-8) 2018-02-23 Jerry DeLisle 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 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 528d294b4e1..673a1b85fbe 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-23 Jerry DeLisle + + 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 PR fortran/83149 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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d68abc56b06..0c703ccd4f2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-23 Jerry DeLisle + + PR fortran/84506 + * gfortran.dg/inquire_19.f90: New test. + 2018-02-23 Paul Thomas PR fortran/83149 diff --git a/gcc/testsuite/gfortran.dg/inquire_19.f90 b/gcc/testsuite/gfortran.dg/inquire_19.f90 new file mode 100644 index 00000000000..7d01b6b56ce --- /dev/null +++ b/gcc/testsuite/gfortran.dg/inquire_19.f90 @@ -0,0 +1,13 @@ +! { 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