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