From: Andrew Pinski Date: Sat, 9 Apr 2005 18:44:07 +0000 (+0000) Subject: re PR fortran/13257 ([4.0 only] Error instead of warning for missing comma in format... X-Git-Tag: misc/cutover-cvs2svn~4213 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53d8a8ac22f1da70288ba496a0f63ca26f3e70dd;p=thirdparty%2Fgcc.git re PR fortran/13257 ([4.0 only] Error instead of warning for missing comma in format string) PR fortran/13257 fortran/ChangeLog: * io.c (check_format): Allow an optional comma between descriptors. libgfortran/ChangeLog: * format.c (parse_format_list): Allow an optional comma between descriptors. testsuite/ChangeLog: * comma_format_extension_[1234].f: New tests. From-SVN: r97919 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 95e2cee227ab..5912cd6d1db5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2005-04-09 Andrew Pinski + + PR fortran/13257 + * io.c (check_format): Allow an optional comma + between descriptors. + 2005-04-09 Francois-Xavier Coudert * match.c (match_arithmetic_if): Remove gfc_ prefix and correct diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 12650f90f24b..90eb855016d7 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -433,6 +433,7 @@ check_format (void) format_item: /* In this state, the next thing has to be a format item. */ t = format_lex (); +format_item_1: switch (t) { case FMT_POSINT: @@ -701,8 +702,10 @@ between_desc: goto syntax; default: - error = "Missing comma"; - goto syntax; + if (gfc_notify_std (GFC_STD_GNU, "Extension: Missing comma at %C") + == FAILURE) + return FAILURE; + goto format_item_1; } optional_comma: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0cee677a70e2..63ea6a80ca41 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-04-09 Andrew Pinski + + PR fortran/13257 + * comma_format_extension_[1234].f: New tests. + 2005-04-09 Jakub Jelinek * gcc.dg/tree-ssa/stdarg-1.c: New test. diff --git a/gcc/testsuite/gfortran.dg/comma_format_extension_1.f b/gcc/testsuite/gfortran.dg/comma_format_extension_1.f new file mode 100644 index 000000000000..a3a5a98f155f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/comma_format_extension_1.f @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "" } +! test that the extension for a missing comma is accepted + + subroutine mysub + dimension ibar(5) + write (3,1001) ( ibar(m), m = 1, 5 ) + + 1001 format (/5x,' ',i4' '/ ) + return + end diff --git a/gcc/testsuite/gfortran.dg/comma_format_extension_2.f b/gcc/testsuite/gfortran.dg/comma_format_extension_2.f new file mode 100644 index 000000000000..7eb17b584340 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/comma_format_extension_2.f @@ -0,0 +1,10 @@ +! { dg-do compile } +! test that the extension for a missing comma is accepted + + subroutine mysub + dimension ibar(5) + write (3,1001) ( ibar(m), m = 1, 5 ) + + 1001 format (/5x,' ',i4' '/ ) ! { dg-warning "Missing comma" } + return + end diff --git a/gcc/testsuite/gfortran.dg/comma_format_extension_3.f b/gcc/testsuite/gfortran.dg/comma_format_extension_3.f new file mode 100644 index 000000000000..15ee18905c42 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/comma_format_extension_3.f @@ -0,0 +1,16 @@ +! PR libfortran/15332 and PR fortran/13257 +! We used to accept this as an extension but +! did do the correct thing at runtime. +! Note the missing , before i1 in the format. +! { do-do run } +! { dg-options "" } + character*12 c + + write (c,100) 0, 1 + if (c .ne. 'i = 0, j = 1') call abort + + write (c,100) 0 + if (c .ne. 'i = 0 ') call abort + + 100 format ('i = 'i1,:,', j = ',i1) + end diff --git a/gcc/testsuite/gfortran.dg/comma_format_extension_4.f b/gcc/testsuite/gfortran.dg/comma_format_extension_4.f new file mode 100644 index 000000000000..5f6ecc5073b6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/comma_format_extension_4.f @@ -0,0 +1,10 @@ +! PR fortran/13257 +! Note the missing , before i1 in the format. +! { do-do run } +! { dg-options "" } + character*5 c + write (c,1001) 1 + if (c .ne. ' 1 ') call abort + + 1001 format (' ',i4' ') + end diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 519591228108..9399d731fcea 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2005-04-09 Andrew Pinski + + PR fortran/13257 + * format.c (parse_format_list): Allow an optional comma + between descriptors. + 2005-04-08 Eric Botcazou * io/backspace.c (unformatted_backspace): Do not dereference diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index f8d858af7a70..5c2d999cbd22 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -452,6 +452,7 @@ parse_format_list (void) /* Get the next format item */ format_item: t = format_lex (); + format_item_1: switch (t) { case FMT_POSINT: @@ -853,8 +854,8 @@ parse_format_list (void) goto finished; default: - error = "Missing comma in format"; - goto finished; + /* Assume a missing comma, this is a GNU extension */ + goto format_item_1; } /* Optional comma is a weird between state where we've just finished