[Bug fortran/54679] Erroneous "Expected P edit descriptor" in conjunction with L descriptor

2016-10-31 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679

Jerry DeLisle  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Jerry DeLisle  ---
Closing, fixed on trunk. I dont see a strong need to backport this, but if
someelse does, just let me know.

[Bug fortran/54679] Erroneous "Expected P edit descriptor" in conjunction with L descriptor

2016-10-31 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679

--- Comment #7 from Jerry DeLisle  ---
Author: jvdelisle
Date: Mon Oct 31 19:59:04 2016
New Revision: 241720

URL: https://gcc.gnu.org/viewcvs?rev=241720=gcc=rev
Log:
2016-10-31  Jerry DeLisle  

PR fortran/54679
* io.c (check_format): Adjust checks for FMT_L to treat a zero
width as an extension, giving warnings or error as appropriate.
Improve messages.
PR libgfortran/54679
* io/format.c (parse_format_list): Adjust checks for FMT_L to
treat a zero width as an extension, giving warnings or error
as appropriate. Improve messages.
PR fortran/54679
* gfortran.dg/fmt_l.f90: Update test.
* gfortran.dg/fmt_l0.f90: New test.

Added:
trunk/gcc/testsuite/gfortran.dg/fmt_l0.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/io.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/fmt_l.f90
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/format.c

[Bug fortran/54679] Erroneous "Expected P edit descriptor" in conjunction with L descriptor

2016-10-28 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679

Jerry DeLisle  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jvdelisle at gcc dot 
gnu.org

--- Comment #6 from Jerry DeLisle  ---
Naturally, every time I have to deal with the error/warning mechanisms, I have
to re-learn it. And, every time, I have to wonder why we do what we do.

In the example, we support L0 as an extension and when seen, it is converted to
a default width of 1.

In the example test case the OP provided the format strings as constant
parameters which allows the compiler to check them at compile time.  The bug is
in how this checking is done and I have a fix for it.

If the strings are changed to variables, they are not checked at compile time
and one must check at run time. For those who may be interested,
philosophically, gfortran tends to avoid unnecessary runtime error messages. In
the given case, L0 will not result in a run time message unless one has used
-pedantic.  Depending on the flag -std= (specified at compile time), the
-pedantic may give a warning or an error.  On error, program execution
terminates. On warning, program execution continues as if nothing happens.

I found the runtime checking of this case not very consistent with the compile
time checking, mostly because the code assumed the unexpected element after the
L was a zero if it was not a positive integer.

I will be submitting a patch to the gfortran list shortly.

As an example, the following does not require -pedantic and will be issued
regardless of the -std= specifier.

At line 8 of file pr54679.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Positive width required with L descriptor
(A,1X,I2,1X,A,1X,I2,1X,A,2(1X,I0,1X),A,2(1X,Lj,1X)) 
 ^
Whereas the following with -pedantic by itself:

At line 8 of file pr54679.f90 (unit = 6, file = 'stdout')
Fortran runtime warning: Zero width after L descriptor

and with -pedantic -std=f95:

At line 8 of file pr54679.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Extension: Zero width after L descriptor
(A,1X,I2,1X,A,1X,I2,1X,A,2(1X,I0,1X),A,2(1X,L0,1X)) 
 ^
Enough said I think.

[Bug fortran/54679] Erroneous "Expected P edit descriptor" in conjunction with L descriptor

2016-10-27 Thread nmm1 at cam dot ac.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679

--- Comment #5 from Nick Maclaren  ---
That's the right message.  Warning or error, it doesn't matter.

[Bug fortran/54679] Erroneous "Expected P edit descriptor" in conjunction with L descriptor

2016-10-27 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679

--- Comment #4 from Jerry DeLisle  ---
I should have looked at this sooner. We actually do diagnose this, but our
warning/error logic is not right.

pr54679.f90:8:56:

 PRINT "(A,1X,I2,1X,A,1X,I2,1X,A,2(1X,I0,1X),A,2(1X,L0,1X))"
1
Warning: Extension: Missing positive width after L descriptor at (1)

[Bug fortran/54679] Erroneous Expected P edit descriptor in conjunction with L descriptor

2013-06-27 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679

Dominique d'Humieres dominiq at lps dot ens.fr changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2013-06-27
 Ever confirmed|0   |1

--- Comment #3 from Dominique d'Humieres dominiq at lps dot ens.fr ---
Still present at revision 200429.


[Bug fortran/54679] Erroneous Expected P edit descriptor in conjunction with L descriptor

2012-09-23 Thread nmm1 at cam dot ac.uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679



--- Comment #1 from Nick Maclaren nmm1 at cam dot ac.uk 2012-09-23 12:19:00 
UTC ---

Please reduce the severity to trivial, and change it to Confusing

diagnostic!  It's my error, at root, but gfortran could do better.



I had forgotten the relevant constraint (C1006 in Fortran 2003).

However, the syntax rule R1005 on the same page specifies that a

width is mandatory for the L descriptor, so the actual error is

that a width of zero is erroneous.


[Bug fortran/54679] Erroneous Expected P edit descriptor in conjunction with L descriptor

2012-09-23 Thread kargl at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54679



kargl at gcc dot gnu.org changed:



   What|Removed |Added



   Priority|P3  |P5

 CC||kargl at gcc dot gnu.org

   Severity|normal  |trivial



--- Comment #2 from kargl at gcc dot gnu.org 2012-09-23 16:24:01 UTC ---

(In reply to comment #1)

 Please reduce the severity to trivial, and change it to Confusing

 diagnostic!  It's my error, at root, but gfortran could do better.

 

 I had forgotten the relevant constraint (C1006 in Fortran 2003).

 However, the syntax rule R1005 on the same page specifies that a

 width is mandatory for the L descriptor, so the actual error is

 that a width of zero is erroneous.



I agree that the error message is confusing. First, the F2008 

constraint is 



C1006 (R1008) w shall be zero or positive for the I, B, O, Z, F,

  and G edit descriptors. w shall be positive for all other

  edit descriptors.



Second, we have 



10.8.5  P editing



   The k P edit descriptor temporarily changes (9.5.2) the scale

   factor for the connection to k . The scale factor affects the

   editing done by the F, E, EN, ES, D, and G edit descriptors

   for numeric quantities.



So P editing does not even apply to the L descriptor.