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

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