This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] Optional comma after string literal in format


On Fri, 21 May 2004, Paul Brook wrote:
> > 2004-05-20  Roger Sayle  <roger@eyesopen.com>
> >
> > 	* io.c (format_item): If we're not being pedantic, allow the
> > 	comma after a string literal to be optional in a format.
> >
> > 	* io/format.c (parse_format_list): Allow the comma after a string
> > 	literal to be optional.
>
> Ok if changed to use gfc_notify_std.

Many thanks.  For the record, here's what I've just committed.  The
following patch was tested on i686-pc-linux-gnu with a full bootstrap,
including gfortran, and tested with a top-level "make -k check" with
no new failures.


2004-05-20  Roger Sayle  <roger@eyesopen.com>

	* io.c (check_format): As a GNU extension, allow the comma after a
	string literal to be optional in a format.  Use gfc_notify_std to
	issue an error/warning as appropriate.

	* io/format.c (parse_format_list): Allow the comma after a string
	literal to be optional.


Index: gcc/fortran/io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/io.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 io.c
*** gcc/fortran/io.c	20 May 2004 18:56:33 -0000	1.4
--- gcc/fortran/io.c	21 May 2004 17:48:47 -0000
*************** format_item:
*** 480,488 ****

      case FMT_SIGN:
      case FMT_BLANK:
-     case FMT_CHAR:
        goto between_desc;

      case FMT_COLON:
      case FMT_SLASH:
        goto optional_comma;
--- 480,490 ----

      case FMT_SIGN:
      case FMT_BLANK:
        goto between_desc;

+     case FMT_CHAR:
+       goto extension_optional_comma;
+
      case FMT_COLON:
      case FMT_SLASH:
        goto optional_comma;
*************** optional_comma:
*** 721,726 ****
--- 723,760 ----

      default:
        /* Assume that we have another format item.  */
+       saved_token = t;
+       break;
+     }
+
+   goto format_item;
+
+ extension_optional_comma:
+   /* As a GNU extension, permit a missing comma after a string literal.  */
+   t = format_lex ();
+   switch (t)
+     {
+     case FMT_COMMA:
+       break;
+
+     case FMT_RPAREN:
+       level--;
+       if (level < 0)
+ 	goto finished;
+       goto between_desc;
+
+     case FMT_COLON:
+     case FMT_SLASH:
+       goto optional_comma;
+
+     case FMT_END:
+       error = unexpected_end;
+       goto syntax;
+
+     default:
+       if (gfc_notify_std (GFC_STD_GNU, "Extension: Missing comma at %C")
+ 	  == FAILURE)
+ 	return FAILURE;
        saved_token = t;
        break;
      }
Index: libgfortran/io/format.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/format.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 format.c
*** libgfortran/io/format.c	16 May 2004 18:21:42 -0000	1.4
--- libgfortran/io/format.c	21 May 2004 17:48:47 -0000
*************** format_item:
*** 543,549 ****
        tail->u.string.p = string;
        tail->u.string.length = value;
        tail->repeat = 1;
!       goto between_desc;

      case FMT_S:
      case FMT_SS:
--- 543,549 ----
        tail->u.string.p = string;
        tail->u.string.length = value;
        tail->repeat = 1;
!       goto optional_comma;

      case FMT_S:
      case FMT_SS:


Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]