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

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