From 1cc51d4d0164baa1f4e8d86699c3243363ae3c44 Mon Sep 17 00:00:00 2001 From: jvdelisle Date: Mon, 24 Aug 2009 04:41:51 +0000 Subject: [PATCH] 2009-08-23 Jerry DeLisle PR fortran/35754 * io.c (check_format): Add checks for comma and the allowed format specifiers after the 'P' specifier. Fix typo in error message and adjust locus. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151045 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/io.c | 35 +++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1ac3066..a5e5b44 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,12 @@ 2009-08-23 Jerry DeLisle + PR fortran/35754 + * io.c (check_format): Add checks for comma and the allowed + format specifiers after the 'P' specifier. Fix typo in error message + and adjust locus. + +2009-08-23 Jerry DeLisle + PR fortran/37446 * io.c (enum format_token): Change FMT_EXT to FMT_EN and FMT_ES. (format_lex): Likewise. diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 456a38c..7191a58 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -687,20 +687,35 @@ data_desc: break; case FMT_P: - if (pedantic) + /* Comma after P is allowed only for F, E, EN, ES, D, or G. + 10.1.1 (1). */ + t = format_lex (); + if (t == FMT_ERROR) + goto fail; + if (gfc_option.allow_std < GFC_STD_F2003 && t != FMT_COMMA + && t != FMT_F && t != FMT_E && t != FMT_EN && t != FMT_ES + && t != FMT_D && t != FMT_G) + { + error = _("Comma required after P descriptor"); + goto syntax; + } + if (t != FMT_COMMA) { - t = format_lex (); - if (t == FMT_ERROR) - goto fail; if (t == FMT_POSINT) { - error = _("Repeat count cannot follow P descriptor"); + t = format_lex (); + if (t == FMT_ERROR) + goto fail; + } + if (t != FMT_F && t != FMT_E && t != FMT_EN && t != FMT_ES && t != FMT_D + && t != FMT_G) + { + error = _("Comma required after P descriptor"); goto syntax; } - - saved_token = t; } + saved_token = t; goto optional_comma; case FMT_T: @@ -883,13 +898,13 @@ data_desc: if (t != FMT_PERIOD) { /* Warn if -std=legacy, otherwise error. */ - if (mode != MODE_FORMAT) - format_locus.nextc += format_string_pos; if (gfc_option.warn_std != 0) { - error = _("Period required in format specifier at %L"); + error = _("Period required in format specifier"); goto syntax; } + if (mode != MODE_FORMAT) + format_locus.nextc += format_string_pos; gfc_warning ("Period required in format specifier at %L", &format_locus); saved_token = t; -- 2.7.4