diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-09-05 18:14:34 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-09-05 18:14:34 +0000 |
commit | 0e521c64613e0407bd086a26322402b29daeb370 (patch) | |
tree | a4f9c3764d80573e09b33875901f2db9e2fee4e6 /gcc/fortran/decl.c | |
parent | bb64bef659dc5b11fe1f8ff1f7df65603c9d8876 (diff) | |
download | gcc-0e521c64613e0407bd086a26322402b29daeb370.zip gcc-0e521c64613e0407bd086a26322402b29daeb370.tar.gz gcc-0e521c64613e0407bd086a26322402b29daeb370.tar.bz2 |
re PR fortran/91660 (Missing error on invalid type declaration)
2019-09-05 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91660
* decl.c (gfc_match_decl_type_spec): Improve and restore error
message for malformed types-spec.
2019-09-05 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91660
* gfortran.dg/pdt_4.f03: Fix invalid code.
* gfortran.dg/pr91660_1.f90: New test.
* gfortran.dg/pr91660_2.f90: Ditto.
From-SVN: r275426
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 0711191..278882d 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -4023,7 +4023,6 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) return MATCH_YES; } - m = gfc_match (" type ("); matched_type = (m == MATCH_YES); if (matched_type) @@ -4071,7 +4070,10 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) m = MATCH_YES; if (matched_type && m == MATCH_YES && gfc_match_char (')') != MATCH_YES) - m = MATCH_ERROR; + { + gfc_error ("Malformed type-spec at %C"); + return MATCH_ERROR; + } return m; } @@ -4094,8 +4096,12 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) && !gfc_notify_std (GFC_STD_F2008, "TYPE with " "intrinsic-type-spec at %C")) return MATCH_ERROR; + if (matched_type && gfc_match_char (')') != MATCH_YES) - return MATCH_ERROR; + { + gfc_error ("Malformed type-spec at %C"); + return MATCH_ERROR; + } ts->type = BT_REAL; ts->kind = gfc_default_double_kind; @@ -4125,7 +4131,10 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) return MATCH_ERROR; if (matched_type && gfc_match_char (')') != MATCH_YES) - return MATCH_ERROR; + { + gfc_error ("Malformed type-spec at %C"); + return MATCH_ERROR; + } ts->type = BT_COMPLEX; ts->kind = gfc_default_double_kind; @@ -4146,7 +4155,13 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) if (m == MATCH_ERROR) return m; - m = gfc_match_char (')'); + gfc_gobble_whitespace (); + if (gfc_peek_ascii_char () != ')') + { + gfc_error ("Malformed type-spec at %C"); + return MATCH_ERROR; + } + m = gfc_match_char (')'); /* Burn closing ')'. */ } if (m != MATCH_YES) |