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]

[gfortran] Allow digits before X format to be optional


The following patch implements an extension to allow the number in
front of the X format to be optional, unless we're being pedantic.  This
fixes the failure of g77.torture/compile/xformat.f when using the new
gfortran compiler.  This patch is conceptually similar to my original
patch that added support for this extension to g77.
http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01465.html

To quote gfortran's own runtime library (libgfortran/io/format.c):

    case FMT_X:
/*
   EXTENSION!

   If we would be pedantic in the library, we would have to reject
   an X descriptor without an integer prefix:

      error = "X descriptor requires leading space count";
      goto finished;

   However, this is an extension supported by many Fortran compilers,
   including Cray, HP, AIX, and IRIX.  Therefore, we allow it in the
   runtime library, and make the front end reject it if the compiler
   is in pedantic mode.  The interpretation of 'X' is '1X'.
*/

The patch below implements the missing functionality implied at the
end of this comment :>


The following patch has been tested by a full bootstrap, including
gfortran, and a top-level "make -k check" on i686-pc-linux-gnu with
no new failures.  I've also confirmed by actually running the
xformat.f testcase that the output is as expected, and that we
continue to issue an error with the -pedantic command line option.

Ok for mainline?


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

	* io.c (format_item): Allow the number before the X format to
	be optional when not -pedantic.


Index: io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/io.c,v
retrieving revision 1.3
diff -c -3 -p -r1.3 io.c
*** io.c	14 May 2004 13:00:04 -0000	1.3
--- io.c	20 May 2004 16:26:14 -0000
*************** format_item:
*** 467,477 ****
        goto data_desc;

      case FMT_P:
!       /* P and X require a prior number.  */
        error = "P descriptor requires leading scale factor";
        goto syntax;

      case FMT_X:
        error = "X descriptor requires leading space count";
        goto syntax;

--- 467,480 ----
        goto data_desc;

      case FMT_P:
!       /* P requires a prior number.  */
        error = "P descriptor requires leading scale factor";
        goto syntax;

      case FMT_X:
+       /* X requires a prior number if we're being pedantic.  */
+       if (!pedantic)
+ 	goto between_desc;
        error = "X descriptor requires leading space count";
        goto syntax;


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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