https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84506

--- Comment #11 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Tentative patch. Testing now. The intent originally was to prevent unit numbers
that don't fit into kind=4.  It use to be we had no negative unit numbers. With
newunit, now we do.

I need to see if this patch allows any invalid code.


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,

Reply via email to