https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30372
--- Comment #11 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #10)
> The non-standard SLEEP intrinsic subroutine is documented as taking a
> default integer argument. This patch enforces this restriction.
>
> Index: gcc/fortran/check.c
> ===================================================================
> --- gcc/fortran/check.c (revision 280157)
> +++ gcc/fortran/check.c (working copy)
> @@ -5588,6 +5588,9 @@ gfc_check_sleep_sub (gfc_expr *seconds)
> if (!scalar_check (seconds, 0))
> return false;
>
> + if (!kind_value_check (seconds, 0, gfc_default_integer_kind))
> + return false;
> +
> return true;
> }
Perhaps, a better patch. This effectively makes SLEEP a generic
procedure by converting the SECONDS argument to default integer
kind.
Index: gcc/fortran/iresolve.c
===================================================================
--- gcc/fortran/iresolve.c (revision 280157)
+++ gcc/fortran/iresolve.c (working copy)
@@ -3699,14 +3699,19 @@ void
gfc_resolve_sleep_sub (gfc_code *c)
{
const char *name;
- int kind;
+ gfc_typespec ts;
+ gfc_expr *n;
+ gfc_clear_ts (&ts);
- if (c->ext.actual->expr != NULL)
- kind = c->ext.actual->expr->ts.kind;
- else
- kind = gfc_default_integer_kind;
+ /* The argument to SLEEP has to be of default kind. If it is not,
+ we convert it. */
+ ts.type = BT_INTEGER;
+ ts.kind = gfc_default_integer_kind;
+ n = c->ext.actual->expr;
+ if (n != NULL && n->ts.kind != ts.kind)
+ gfc_convert_type (n, &ts, 2);
- name = gfc_get_string (PREFIX ("sleep_i%d_sub"), kind);
+ name = gfc_get_string (PREFIX ("sleep_i%d_sub"), ts.kind);
c->resolved_sym = gfc_get_intrinsic_sub_symbol (name);
}
Index: gcc/fortran/intrinsic.texi
===================================================================
--- gcc/fortran/intrinsic.texi (revision 280157)
+++ gcc/fortran/intrinsic.texi (working copy)
@@ -13557,7 +13557,8 @@ Subroutine
@item @emph{Arguments}:
@multitable @columnfractions .15 .70
-@item @var{SECONDS} @tab The type shall be of default @code{INTEGER}.
+@item @var{SECONDS} @tab @var{SECONDS} shall be scalar with an
+@code{INTEGER} type.
@end multitable
@item @emph{Example}: