This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] PR35754 -std=f95: Reject "1P2E12.4" w/o a comma after the "P"
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 23 Aug 2009 12:24:57 -0700
- Subject: [patch, fortran] PR35754 -std=f95: Reject "1P2E12.4" w/o a comma after the "P"
The attached patch fixes the diagnostics for the subject case and adds
checks for the acceptable format specifiers after a P without a comma. I
will be looking into the runtime side of these fixes after this is
committed.
Regression tested on x86-64 Linux. Test case included.
OK for trunk.
Note: The patch may be offset a bit since my trunk has the patch for
37446 in it.
Regards,
Jerry
2009-08-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/35754
* io.c (check_format): Add checks for comma and the allowed
format specifiers after the 'P' specifier.
Index: io.c
===================================================================
--- io.c (revision 151021)
+++ io.c (working copy)
@@ -664,20 +687,35 @@
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)
{
- t = format_lex ();
- if (t == FMT_ERROR)
- goto fail;
+ error = _("Comma required after P descriptor");
+ goto syntax;
+ }
+ if (t != FMT_COMMA)
+ {
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:
! { dg-do compile }
! { dg-options "-std=f95" }
! PR35754 -std=f95: Reject "1P2E12.4" w/o a comma after the "P"
! Test case provided by Jerry DeLisle <jvdelisle@gcc.gnu.org>
character(40) :: fmt_string
write(*, '(1P2E12.4)') 1.0 ! { dg-error "Comma required" }
write(*, '(1PT12,F12.4)') 1.0 ! { dg-error "Comma required" }
write(*, '(1PE12.4)') 1.0 ! This is OK by the standard 10.1.1
end