From: Steven G. Kargl Date: Fri, 1 Nov 2019 16:59:06 +0000 (+0000) Subject: decl.c (match_byte_typespec): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2028ce454f4d9424aaf05c27b20f13ea52748caf;p=gcc.git decl.c (match_byte_typespec): New function. 2019-11-01 Steven G. Kargl * decl.c (match_byte_typespec): New function. Match BYTE type-spec. (gfc_match_decl_type_spec): Use it. 2019-11-01 Steven G. Kargl * gfortran.dg/byte_3.f: New test. * gfortran.dg/byte_4.f90: Ditto. From-SVN: r277715 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 34d7a718c33..74211ced3fd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2019-11-01 Steven G. Kargl + + * decl.c (match_byte_typespec): New function. Match BYTE type-spec. + (gfc_match_decl_type_spec): Use it. + 2019-11-01 Steven G. Kargl PR fortran/90988 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 652b578b0dd..7858973cc20 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -3980,6 +3980,38 @@ error_return: } +/* Match a legacy nonstandard BYTE type-spec. */ + +static match +match_byte_typespec (gfc_typespec *ts) +{ + if (gfc_match (" byte") == MATCH_YES) + { + if (!gfc_notify_std (GFC_STD_GNU, "BYTE type at %C")) + return MATCH_ERROR; + + if (gfc_current_form == FORM_FREE) + { + char c = gfc_peek_ascii_char (); + if (!gfc_is_whitespace (c) && c != ',') + return MATCH_NO; + } + + if (gfc_validate_kind (BT_INTEGER, 1, true) < 0) + { + gfc_error ("BYTE type used at %C " + "is not available on the target machine"); + return MATCH_ERROR; + } + + ts->type = BT_INTEGER; + ts->kind = 1; + return MATCH_YES; + } + return MATCH_NO; +} + + /* Matches a declaration-type-spec (F03:R502). If successful, sets the ts structure to the matched specification. This is necessary for FUNCTION and IMPLICIT statements. @@ -4012,22 +4044,10 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) /* Clear the current binding label, in case one is given. */ curr_binding_label = NULL; - if (gfc_match (" byte") == MATCH_YES) - { - if (!gfc_notify_std (GFC_STD_GNU, "BYTE type at %C")) - return MATCH_ERROR; - - if (gfc_validate_kind (BT_INTEGER, 1, true) < 0) - { - gfc_error ("BYTE type used at %C " - "is not available on the target machine"); - return MATCH_ERROR; - } - - ts->type = BT_INTEGER; - ts->kind = 1; - return MATCH_YES; - } + /* Match BYTE type-spec. */ + m = match_byte_typespec (ts); + if (m != MATCH_NO) + return m; m = gfc_match (" type ("); matched_type = (m == MATCH_YES); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e7dec2ec882..8b03bd9913e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-01 Steven G. Kargl + + * gfortran.dg/byte_3.f: New test. + * gfortran.dg/byte_4.f90: Ditto. + 2019-11-01 Steven G. Kargl PR fortran/90988 diff --git a/gcc/testsuite/gfortran.dg/byte_3.f b/gcc/testsuite/gfortran.dg/byte_3.f new file mode 100644 index 00000000000..35ee82878fc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/byte_3.f @@ -0,0 +1,6 @@ +c { dg-do run } +c { dg-options "-std=legacy" } + bytea + a = 1 + if (a /= 1 .and. kind(a) /= a) stop 1 + end diff --git a/gcc/testsuite/gfortran.dg/byte_4.f90 b/gcc/testsuite/gfortran.dg/byte_4.f90 new file mode 100644 index 00000000000..06873e5195c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/byte_4.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-w" } + bytea ! { dg-error "Unclassifiable statement" } + byte b + byte :: d + a = 1 + b = 1 + d = 1 + print *, a, b * d + end