Blame SOURCES/0006-Allow-blank-format-items-in-format-strings.patch

0714f1
From 8a5920d930429f91b269d9265323bf2507a6b8e5 Mon Sep 17 00:00:00 2001
0714f1
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
0714f1
Date: Thu, 4 Feb 2016 16:59:41 +0000
0714f1
Subject: [PATCH 06/16] Allow blank format items in format strings
0714f1
0714f1
This has to be written in a slightly verbose manner because GCC 7
0714f1
defaults to building with -Werror=implicit-fallthrough which prevents
0714f1
us from just falling through to the default: case.
0714f1
0714f1
Test written by: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
0714f1
0714f1
Use -fdec-blank-format-item to enable. Also enabled by -fdec.
0714f1
---
0714f1
 gcc/fortran/io.c                                    | 10 ++++++++++
0714f1
 gcc/fortran/lang.opt                                |  4 ++++
0714f1
 gcc/fortran/options.c                               |  1 +
0714f1
 gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f | 19 +++++++++++++++++++
0714f1
 gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f | 19 +++++++++++++++++++
0714f1
 gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f | 19 +++++++++++++++++++
0714f1
 6 files changed, 72 insertions(+)
0714f1
 create mode 100644 gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f
0714f1
 create mode 100644 gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f
0714f1
 create mode 100644 gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f
0714f1
0714f1
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
0714f1
index 57117579627..5b355952840 100644
0714f1
--- a/gcc/fortran/io.c
0714f1
+++ b/gcc/fortran/io.c
0714f1
@@ -756,6 +756,16 @@ format_item_1:
0714f1
       error = unexpected_end;
0714f1
       goto syntax;
0714f1
 
0714f1
+    case FMT_RPAREN:
0714f1
+      /* Oracle allows a blank format item. */
0714f1
+      if (flag_dec_blank_format_item)
0714f1
+	goto finished;
0714f1
+      else
0714f1
+	{
0714f1
+	  error = unexpected_element;
0714f1
+	  goto syntax;
0714f1
+	}
0714f1
+
0714f1
     default:
0714f1
       error = unexpected_element;
0714f1
       goto syntax;
0714f1
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
0714f1
index a957b90707f..3d8aaeaaf44 100644
0714f1
--- a/gcc/fortran/lang.opt
0714f1
+++ b/gcc/fortran/lang.opt
0714f1
@@ -440,6 +440,10 @@ fdec
0714f1
 Fortran Var(flag_dec)
0714f1
 Enable all DEC language extensions.
0714f1
 
0714f1
+fdec-blank-format-item
0714f1
+Fortran Var(flag_dec_blank_format_item)
0714f1
+Enable the use of blank format items in format strings.
0714f1
+
0714f1
 fdec-duplicates
0714f1
 Fortran Var(flag_dec_duplicates)
0714f1
 Allow varibles to be duplicated in the type specification matches.
0714f1
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
0714f1
index b652be70f3d..a8c2cf71c3b 100644
0714f1
--- a/gcc/fortran/options.c
0714f1
+++ b/gcc/fortran/options.c
0714f1
@@ -78,6 +78,7 @@ set_dec_flags (int value)
0714f1
   SET_BITFLAG (flag_dec_duplicates, value, value);
0714f1
   SET_BITFLAG (flag_dec_char_conversions, value, value);
0714f1
   SET_BITFLAG (flag_dec_comparisons, value, value);
0714f1
+  SET_BITFLAG (flag_dec_blank_format_item, value, value);
0714f1
 }
0714f1
 
0714f1
 /* Finalize DEC flags.  */
0714f1
diff --git a/gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f b/gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f
0714f1
new file mode 100644
0714f1
index 00000000000..ed27c18944b
0714f1
--- /dev/null
0714f1
+++ b/gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f
0714f1
@@ -0,0 +1,19 @@
0714f1
+! { dg-do run }
0714f1
+! { dg-options "-fdec" }
0714f1
+!
0714f1
+! Test blank/empty format items in format string
0714f1
+!
0714f1
+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
0714f1
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
0714f1
+!
0714f1
+        PROGRAM blank_format_items
0714f1
+          INTEGER A/0/
0714f1
+
0714f1
+          OPEN(1, status="scratch")
0714f1
+          WRITE(1, 10) 100
0714f1
+          REWIND(1)
0714f1
+          READ(1, 10) A
0714f1
+          IF (a.NE.100) STOP 1
0714f1
+          PRINT 10, A
0714f1
+10        FORMAT( I5,)
0714f1
+        END
0714f1
diff --git a/gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f b/gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f
0714f1
new file mode 100644
0714f1
index 00000000000..2793cb16225
0714f1
--- /dev/null
0714f1
+++ b/gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f
0714f1
@@ -0,0 +1,19 @@
0714f1
+! { dg-do run }
0714f1
+! { dg-options "-fdec-blank-format-item" }
0714f1
+!
0714f1
+! Test blank/empty format items in format string
0714f1
+!
0714f1
+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
0714f1
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
0714f1
+!
0714f1
+        PROGRAM blank_format_items
0714f1
+          INTEGER A/0/
0714f1
+
0714f1
+          OPEN(1, status="scratch")
0714f1
+          WRITE(1, 10) 100
0714f1
+          REWIND(1)
0714f1
+          READ(1, 10) A
0714f1
+          IF (a.NE.100) STOP 1
0714f1
+          PRINT 10, A
0714f1
+10        FORMAT( I5,)
0714f1
+        END
0714f1
diff --git a/gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f b/gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f
0714f1
new file mode 100644
0714f1
index 00000000000..499db922876
0714f1
--- /dev/null
0714f1
+++ b/gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f
0714f1
@@ -0,0 +1,19 @@
0714f1
+! { dg-do compile }
0714f1
+! { dg-options "-fdec -fno-dec-blank-format-item" }
0714f1
+!
0714f1
+! Test blank/empty format items in format string
0714f1
+!
0714f1
+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
0714f1
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
0714f1
+!
0714f1
+        PROGRAM blank_format_items
0714f1
+          INTEGER A/0/
0714f1
+
0714f1
+          OPEN(1, status="scratch")
0714f1
+          WRITE(1, 10) 100 ! { dg-error "FORMAT label 10 at \\(1\\) not defined" }
0714f1
+          REWIND(1)
0714f1
+          READ(1, 10) A ! { dg-error "FORMAT label 10 at \\(1\\) not defined" }
0714f1
+          IF (a.NE.100) STOP 1
0714f1
+          PRINT 10, A ! { dg-error "FORMAT label 10 at \\(1\\) not defined" }
0714f1
+10        FORMAT( I5,) ! { dg-error "Unexpected element" }
0714f1
+        END
0714f1
-- 
0714f1
2.11.0
0714f1