Blob Blame History Raw
From f50b0452c10d514860e08e1ea091b17aa97d6a90 Mon Sep 17 00:00:00 2001
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
Date: Thu, 4 Feb 2016 16:59:41 +0000
Subject: [PATCH 06/23] Allow blank format items in format strings

This has to be written in a slightly verbose manner because GCC 7
defaults to building with -Werror=implicit-fallthrough which prevents
us from just falling through to the default: case.

This feature is enabled by the `-std=extra-legacy` compiler flag.
---
        0006-Allow-blank-format-items-in-format-strings.patch

commit 8e205f3940a364318d0cd2197a9897142632b336
Author: Jim MacArthur <jim.macarthur@codethink.co.uk>
Date:   Thu Feb 4 16:59:41 2016 +0000

    Allow blank format items in format strings
    
    This has to be written in a slightly verbose manner because GCC 7
    defaults to building with -Werror=implicit-fallthrough which prevents
    us from just falling through to the default: case.
    
    This feature is enabled by the `-std=extra-legacy` compiler flag.
    
    Test written by: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>

diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index 0bec4ee39b2..d93dcfadd61 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -752,6 +752,16 @@ format_item_1:
       error = unexpected_end;
       goto syntax;
 
+    case FMT_RPAREN:
+      /* Oracle allows a blank format item. */
+      if (gfc_option.allow_std & GFC_STD_EXTRA_LEGACY)
+        goto finished;
+      else
+	{
+	  error = unexpected_element;
+	  goto syntax;
+	}
+
     default:
       error = unexpected_element;
       goto syntax;
diff --git a/gcc/testsuite/gfortran.dg/dec_format_empty_item.f b/gcc/testsuite/gfortran.dg/dec_format_empty_item.f
new file mode 100644
index 00000000000..e817001e38a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dec_format_empty_item.f
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! { dg-options "-std=extra-legacy" }
+!
+! Test blank/empty format items in format string
+!
+        PROGRAM blank_format_items
+          INTEGER A/0/
+
+          OPEN(1, status="scratch")
+          WRITE(1, 10) 100
+          REWIND(1)
+          READ(1, 10) A
+          IF (a.NE.100) STOP 1
+          PRINT 10, A
+10        FORMAT( I5,)
+        END