--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f95 -pedantic" }
+
+character(20) :: fmt
+character(9) :: buffer
+fmt = "(1a1,f0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 1
+end
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2008 -pedantic" }
+! { dg-shouldfail "Zero width in format descriptor" }
+
+character(10) :: fmt = "(es0.2)"
+print fmt, 3.
+end
+
+! { dg-output "Fortran runtime error: Zero width in format descriptor" }
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2003 -pedantic" }
+
+character(20) :: fmt
+character(9) :: buffer
+fmt = "(1a1,f0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 1
+end
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2008 -pedantic" }
+
+character(20) :: fmt
+character(9) :: buffer
+fmt = "(1a1,f0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 1
+fmt = "(1a1,g0.2,1a1)"
+write(buffer,fmt) ">", 0.3, "<"
+if (buffer.ne.">0.30<") stop 2
+end
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2018 -pedantic" }
+
+character(20) :: fmt
+character(9) :: buffer
+fmt = "(1a1,f0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 1
+fmt = "(1a1,g0.2,1a1)"
+write(buffer,fmt) ">", 0.3, "<"
+if (buffer.ne.">0.30<") stop 2
+fmt = "(1a1,d0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">0.30D+1<") stop 3
+fmt = "(1a1,e0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">0.30E+1<") stop 4
+fmt = "(1a1,en0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 5
+fmt = "(1a1,es0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 6
+end
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-pedantic" }
+
+character(20) :: fmt
+character(9) :: buffer
+fmt = "(1a1,f0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 1
+fmt = "(1a1,g0.2,1a1)"
+write(buffer,fmt) ">", 0.30, "<"
+if (buffer.ne.">0.30<") stop 2
+fmt = "(1a1,d0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">0.30D+1<") stop 3
+fmt = "(1a1,e0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">0.30E+1<") stop 4
+fmt = "(1a1,en0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 5
+fmt = "(1a1,es0.2,1a1)"
+write(buffer,fmt) ">", 3.0, "<"
+if (buffer.ne.">3.00<") stop 6
+end
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2003 -pedantic" }
+! { dg-shouldfail "Zero width in format descriptor" }
+
+character(10) :: fmt = "(g0.2)"
+print fmt, 0.3
+end
+
+! { dg-output "Fortran runtime error: Zero width in format descriptor" }
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2008 -pedantic" }
+! { dg-shouldfail "Zero width in format descriptor" }
+
+character(10) :: fmt = "(d0.2)"
+print fmt, 3.
+end
+
+! { dg-output "Fortran runtime error: Zero width in format descriptor" }
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2008 -pedantic" }
+! { dg-shouldfail "Zero width in format descriptor" }
+
+character(10) :: fmt = "(e0.2)"
+print fmt, 3.
+end
+
+! { dg-output "Fortran runtime error: Zero width in format descriptor" }
+
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=f2008 -pedantic" }
+! { dg-shouldfail "Zero width in format descriptor" }
+
+character(10) :: fmt = "(en0.2)"
+print fmt, 3.
+end
+
+! { dg-output "Fortran runtime error: Zero width in format descriptor" }
+
int repeat;
format_data *fmt = dtp->u.p.fmt;
bool seen_data_desc = false;
+ int standard;
head = tail = NULL;
/* Processing for zero width formats. */
if (u == FMT_ZERO)
{
- if (notification_std (GFC_STD_F2008) == NOTIFICATION_ERROR
+ if (t == FMT_F)
+ standard = GFC_STD_F95;
+ else if (t == FMT_G)
+ standard = GFC_STD_F2008;
+ else
+ standard = GFC_STD_F2018;
+
+ if (notification_std (standard) == NOTIFICATION_ERROR
|| dtp->u.p.mode == READING)
{
fmt->error = zero_width;