This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] PR38398 g0.w edit descriptor: Update for F2008 Tokyo meeting changes
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Cc: Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 13 Dec 2008 23:36:11 -0800
- Subject: [patch, fortran] PR38398 g0.w edit descriptor: Update for F2008 Tokyo meeting changes
Hi all
I have this little tweak to fortran/io.c that nails the error loci for formats
and adjusts the g0 behaviour at run-time.
I have not had a chance to test the error loci aspect on very many test cases,
so please feel free to exercise this. Here is an example output:
fmt_g0_4.f90:5.17:
write(*,'(a,g0.4e4,a)') ">",3.45e65_8,"<"
1
Error: E specifier not allowed with g0 descriptor in format string at (1)
I think its safe for 4.4 and it is part of the g0 patch which is a wrong code
bug fix.
Regression tested on x86-64. I need to dejagnu the test case and make a change
log entry.
OK for trunk or wait for 4.5?
Jerry
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (revision 142534)
+++ gcc/fortran/io.c (working copy)
@@ -118,6 +118,7 @@ format_token;
used to back up by a single format token during the parsing
process. */
static gfc_char_t *format_string;
+static int format_string_pos;
static int format_length, use_last_char;
static char error_element;
static locus format_locus;
@@ -169,6 +170,7 @@ next_char (int in_string)
if (mode != MODE_STRING)
format_locus = gfc_current_locus;
+ format_string_pos++;
c = gfc_wide_toupper (c);
return c;
@@ -503,6 +505,7 @@ check_format (bool is_input)
level = 0;
repeat = 0;
rv = SUCCESS;
+ format_string_pos = 0;
t = format_lex ();
if (t == FMT_ERROR)
@@ -729,15 +732,19 @@ data_desc:
saved_token = u;
break;
}
-
u = format_lex ();
- if (u == FMT_ERROR)
- goto fail;
if (u != FMT_POSINT)
{
error = posint_required;
goto syntax;
}
+ u = format_lex ();
+ if (u == FMT_E)
+ {
+ error = _("E specifier not allowed with g0 descriptor");
+ goto syntax;
+ }
+ saved_token = u;
break;
}
@@ -983,6 +990,8 @@ extension_optional_comma:
goto format_item;
syntax:
+ if (mode != MODE_FORMAT)
+ format_locus.nextc += format_string_pos;
if (error == unexpected_element)
gfc_error (error, error_element, &format_locus);
else
Index: libgfortran/io/write.c
===================================================================
--- libgfortran/io/write.c (revision 142747)
+++ libgfortran/io/write.c (working copy)
@@ -1010,13 +1010,11 @@ void
write_real_g0 (st_parameter_dt *dtp, const char *source, int length, int d)
{
fnode f ;
- int org_scale = dtp->u.p.scale_factor;
- dtp->u.p.scale_factor = 1;
set_fnode_default (dtp, &f, length);
- f.format = FMT_ES;
+ f.format = FMT_F;
f.u.real.d = d;
+ f.u.real.w = 0;
write_float (dtp, &f, source , length);
- dtp->u.p.scale_factor = org_scale;
}
! { dg-do compile }
! { dg-options "-std=f2008" }
! PR36725 Compile time error for g0 edit descriptor
write(*,'(a,g10.4,a)') ">",3.45,"<"
write(*,'(a,g0.4e4,a)') ">",3.45e65_8,"<"
write(*,100) ">",3.45e65_8,"<"
100 format (a,g0.4e4,a)
end