Please find attached the patch and a ChangeLog entry. This is my first
patch, apologies for any mistakes in the submission process.
This patch is the simple removal of an OPT_dec_structure case from a
switch statement, it was noticeable as there was no corresponding code
for the other dec specific options. I spotted this before the creation
of PR fortran/87919 so I now know that this fixes the broken behaviour
of -fno-dec-structure.
The patch contains a change to gcc/fortran/options.c and four testcases
pr87919-dec-structure-*.f where * is one of 1, 2, 3 and 4.
The testcases are specified to compile with no specific options, -fdec,
-fdec-structure and both -fdec and -fno-dec-structure.
After building the compiler on x86_64 I got the following results
aggregated from make -j 5 check-fortran:
=== gfortran Summary ===
# of expected passes 48184
# of expected failures 103
# of unsupported tests 79
--
https://www.codethink.co.uk/privacy.html
PR fortran/87919
* options.c (gfc_handle_option): Removed case OPT_fdec_structure
as it breaks the handling of -fno-dec-structure.
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 73f5389361d9..3b7c2d40fe8a 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -761,10 +761,6 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
/* Enable all DEC extensions. */
set_dec_flags (1);
break;
-
- case OPT_fdec_structure:
- flag_dec_structure = 1;
- break;
}
Fortran_handle_option_auto (&global_options, &global_options_set,
diff --git a/gcc/testsuite/gfortran.dg/pr87919-dec-structure-1.f b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-1.f
new file mode 100644
index 000000000000..4dd34082b97a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-1.f
@@ -0,0 +1,21 @@
+! { dg-do compile }
+!
+! PR/fortran/87919
+!
+! Should fail to compile without the -fdec or -fdec-structure options
+!
+! Contributed by Mark Eggleston <mark.eggles...@codethink.com>
+
+ program test
+
+ structure /info/ ! { dg-error "-fdec-structure" }
+ integer a
+ real b
+ end structure ! { dg-error "END PROGRAM" }
+
+ record /info/ s ! { dg-error "-fdec-structure" }
+ s.a = 199 ! { dg-error "Unclassifiable" }
+ s.b = 7.6 ! { dg-error "Unclassifiable" }
+ write (*,*) s.a ! { dg-error "Syntax error in WRITE" }
+ write (*,*) s.b ! { dg-error "Syntax error in WRITE" }
+ end program test
diff --git a/gcc/testsuite/gfortran.dg/pr87919-dec-structure-2.f b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-2.f
new file mode 100644
index 000000000000..e2ebfe344abb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-2.f
@@ -0,0 +1,22 @@
+! { dg-do run }
+! { dg-options "-fdec" }
+!
+! PR/fortran/87919
+!
+! Should compile anf run with the -fdec option
+!
+! Contributed by Mark Eggleston <mark.eggles...@codethink.com>
+!
+ program test
+
+ structure /info/
+ integer a
+ real b
+ end structure
+
+ record /info/ s
+ s.a = 199
+ s.b = 7.6
+ if (s.a .ne. 199) stop 1
+ if (abs(s.b - 7.6) .gt. 1e-5) stop 2
+ end program test
diff --git a/gcc/testsuite/gfortran.dg/pr87919-dec-structure-3.f b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-3.f
new file mode 100644
index 000000000000..e543b37a4371
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-3.f
@@ -0,0 +1,22 @@
+! { dg-do run }
+! { dg-options "-fdec-structure" }
+!
+! PR/fortran/87919
+!
+! Should compile anf run with the -fdec option
+!
+! Contributed by Mark Eggleston <mark.eggles...@codethink.com>
+!
+ program test
+
+ structure /info/
+ integer a
+ real b
+ end structure
+
+ record /info/ s
+ s.a = 199
+ s.b = 7.6
+ if (s.a .ne. 199) stop 1
+ if (abs(s.b - 7.6) .gt. 1e-5) stop 2
+ end program test
diff --git a/gcc/testsuite/gfortran.dg/pr87919-dec-structure-4.f b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-4.f
new file mode 100644
index 000000000000..fa5f1d7a3436
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr87919-dec-structure-4.f
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-fdec -fno-dec-structure" }
+!
+! PR/fortran/87919
+!
+! Should fail to compile with the -fdec and -fno-dec-structure option
+!
+! Contributed by Mark Eggleston <mark.eggles...@codethink.com>
+!
+ program test
+
+ structure /info/ ! { dg-error "-fdec-structure" }
+ integer a
+ real b
+ end structure ! { dg-error "END PROGRAM" }
+
+ record /info/ s ! { dg-error "-fdec-structure" }
+ s.a = 199 ! { dg-error "Unclassifiable" }
+ s.b = 7.6 ! { dg-error "Unclassifiable" }
+ write (*,*) s.a ! { dg-error "Syntax error in WRITE" }
+ write (*,*) s.b ! { dg-error "Syntax error in WRITE" }
+ end program test