|
|
999efc |
From fa06ba3a82777721696d78a5718804e508b5bb55 Mon Sep 17 00:00:00 2001
|
|
|
999efc |
From: Mark Eggleston <markeggleston@gcc.gnu.org>
|
|
|
999efc |
Date: Mon, 3 Feb 2020 09:39:48 +0000
|
|
|
999efc |
Subject: [PATCH 09/10] Add the SEQUENCE attribute by default if it's not
|
|
|
999efc |
present.
|
|
|
999efc |
|
|
|
999efc |
Use -fdec-sequence to enable this feature. Also enabled by -fdec.
|
|
|
999efc |
---
|
|
|
999efc |
gcc/fortran/lang.opt | 4 ++
|
|
|
999efc |
gcc/fortran/options.c | 1 +
|
|
|
999efc |
gcc/fortran/resolve.c | 13 +++--
|
|
|
999efc |
...dec_add_SEQUENCE_to_COMMON_block_by_default_1.f | 57 ++++++++++++++++++++++
|
|
|
999efc |
...dec_add_SEQUENCE_to_COMMON_block_by_default_2.f | 57 ++++++++++++++++++++++
|
|
|
999efc |
...dec_add_SEQUENCE_to_COMMON_block_by_default_3.f | 57 ++++++++++++++++++++++
|
|
|
999efc |
6 files changed, 186 insertions(+), 3 deletions(-)
|
|
|
999efc |
create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
|
|
|
999efc |
create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
|
|
|
999efc |
create mode 100644 gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
|
|
|
999efc |
|
|
|
999efc |
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
|
|
|
999efc |
index aceef2aa180..ca2c0e17350 100644
|
|
|
999efc |
--- a/gcc/fortran/lang.opt
|
|
|
999efc |
+++ b/gcc/fortran/lang.opt
|
|
|
999efc |
@@ -505,6 +505,10 @@ fdec-promotion
|
|
|
999efc |
Fortran Var(flag_dec_promotion)
|
|
|
e9307e |
Add support for type promotion in intrinsic arguments.
|
|
|
999efc |
|
|
|
999efc |
+fdec-sequence
|
|
|
999efc |
+Fortran Var(flag_dec_sequence)
|
|
|
e9307e |
+Add the SEQUENCE attribute by default if it's not present.
|
|
|
999efc |
+
|
|
|
999efc |
fdec-structure
|
|
|
999efc |
Fortran Var(flag_dec_structure)
|
|
|
999efc |
Enable support for DEC STRUCTURE/RECORD.
|
|
|
999efc |
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
|
|
|
999efc |
index 82e5c9edf4b..9f594c6b4a3 100644
|
|
|
999efc |
--- a/gcc/fortran/options.c
|
|
|
999efc |
+++ b/gcc/fortran/options.c
|
|
|
999efc |
@@ -83,6 +83,7 @@ set_dec_flags (int value)
|
|
|
999efc |
SET_BITFLAG (flag_dec_override_kind, value, value);
|
|
|
999efc |
SET_BITFLAG (flag_dec_non_logical_if, value, value);
|
|
|
999efc |
SET_BITFLAG (flag_dec_promotion, value, value);
|
|
|
999efc |
+ SET_BITFLAG (flag_dec_sequence, value, value);
|
|
|
999efc |
}
|
|
|
999efc |
|
|
|
999efc |
/* Finalize DEC flags. */
|
|
|
999efc |
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
|
|
|
999efc |
index e4bb0e79c80..10547704455 100644
|
|
|
999efc |
--- a/gcc/fortran/resolve.c
|
|
|
999efc |
+++ b/gcc/fortran/resolve.c
|
|
|
999efc |
@@ -971,9 +971,16 @@ resolve_common_vars (gfc_common_head *common_block, bool named_common)
|
|
|
999efc |
|
|
|
999efc |
if (!(csym->ts.u.derived->attr.sequence
|
|
|
999efc |
|| csym->ts.u.derived->attr.is_bind_c))
|
|
|
999efc |
- gfc_error_now ("Derived type variable %qs in COMMON at %L "
|
|
|
999efc |
- "has neither the SEQUENCE nor the BIND(C) "
|
|
|
999efc |
- "attribute", csym->name, &csym->declared_at);
|
|
|
999efc |
+ {
|
|
|
999efc |
+ if (flag_dec_sequence)
|
|
|
999efc |
+ /* Assume sequence. */
|
|
|
999efc |
+ csym->ts.u.derived->attr.sequence = 1;
|
|
|
999efc |
+ else
|
|
|
999efc |
+ gfc_error_now ("Derived type variable '%s' in COMMON at %L "
|
|
|
999efc |
+ "has neither the SEQUENCE nor the BIND(C) "
|
|
|
999efc |
+ "attribute", csym->name, &csym->declared_at);
|
|
|
999efc |
+ }
|
|
|
999efc |
+
|
|
|
999efc |
if (csym->ts.u.derived->attr.alloc_comp)
|
|
|
999efc |
gfc_error_now ("Derived type variable %qs in COMMON at %L "
|
|
|
999efc |
"has an ultimate component that is "
|
|
|
999efc |
diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
|
|
|
999efc |
new file mode 100644
|
|
|
999efc |
index 00000000000..fe7b39625eb
|
|
|
999efc |
--- /dev/null
|
|
|
999efc |
+++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_1.f
|
|
|
999efc |
@@ -0,0 +1,57 @@
|
|
|
999efc |
+! { dg-do run }
|
|
|
999efc |
+! { dg-options "-fdec" }
|
|
|
999efc |
+!
|
|
|
999efc |
+! Test add default SEQUENCE attribute derived types appearing in
|
|
|
999efc |
+! COMMON blocks and EQUIVALENCE statements.
|
|
|
999efc |
+!
|
|
|
999efc |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
999efc |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
999efc |
+!
|
|
|
999efc |
+ MODULE SEQ
|
|
|
999efc |
+ TYPE STRUCT1
|
|
|
999efc |
+ INTEGER*4 ID
|
|
|
999efc |
+ INTEGER*4 TYPE
|
|
|
999efc |
+ INTEGER*8 DEFVAL
|
|
|
999efc |
+ CHARACTER*(4) NAME
|
|
|
999efc |
+ LOGICAL*1 NIL
|
|
|
999efc |
+ END TYPE STRUCT1
|
|
|
999efc |
+ END MODULE
|
|
|
999efc |
+
|
|
|
999efc |
+ SUBROUTINE A
|
|
|
999efc |
+ USE SEQ
|
|
|
999efc |
+ TYPE (STRUCT1) S
|
|
|
999efc |
+ COMMON /BLOCK1/ S
|
|
|
999efc |
+ IF (S%ID.NE.5) STOP 1
|
|
|
999efc |
+ IF (S%TYPE.NE.1000) STOP 2
|
|
|
999efc |
+ IF (S%DEFVAL.NE.-99) STOP 3
|
|
|
999efc |
+ IF (S%NAME.NE."JANE") STOP 4
|
|
|
999efc |
+ IF (S%NIL.NEQV..FALSE.) STOP 5
|
|
|
999efc |
+ END SUBROUTINE
|
|
|
999efc |
+
|
|
|
999efc |
+ PROGRAM sequence_att_common
|
|
|
999efc |
+ USE SEQ
|
|
|
999efc |
+ IMPLICIT NONE
|
|
|
999efc |
+ TYPE (STRUCT1) S1
|
|
|
999efc |
+ TYPE (STRUCT1) S2
|
|
|
999efc |
+ TYPE (STRUCT1) S3
|
|
|
999efc |
+
|
|
|
999efc |
+ EQUIVALENCE (S1,S2)
|
|
|
999efc |
+ COMMON /BLOCK1/ S3
|
|
|
999efc |
+
|
|
|
999efc |
+ S1%ID = 5
|
|
|
999efc |
+ S1%TYPE = 1000
|
|
|
999efc |
+ S1%DEFVAL = -99
|
|
|
999efc |
+ S1%NAME = "JANE"
|
|
|
999efc |
+ S1%NIL = .FALSE.
|
|
|
999efc |
+
|
|
|
999efc |
+ IF (S2%ID.NE.5) STOP 1
|
|
|
999efc |
+ IF (S2%TYPE.NE.1000) STOP 2
|
|
|
999efc |
+ IF (S2%DEFVAL.NE.-99) STOP 3
|
|
|
999efc |
+ IF (S2%NAME.NE."JANE") STOP 4
|
|
|
999efc |
+ IF (S2%NIL.NEQV..FALSE.) STOP 5
|
|
|
999efc |
+
|
|
|
999efc |
+ S3 = S1
|
|
|
999efc |
+
|
|
|
999efc |
+ CALL A
|
|
|
999efc |
+
|
|
|
999efc |
+ END
|
|
|
999efc |
diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
|
|
|
999efc |
new file mode 100644
|
|
|
999efc |
index 00000000000..83512f0f3a2
|
|
|
999efc |
--- /dev/null
|
|
|
999efc |
+++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_2.f
|
|
|
999efc |
@@ -0,0 +1,57 @@
|
|
|
999efc |
+! { dg-do run }
|
|
|
999efc |
+! { dg-options "-fdec-sequence" }
|
|
|
999efc |
+!
|
|
|
999efc |
+! Test add default SEQUENCE attribute derived types appearing in
|
|
|
999efc |
+! COMMON blocks and EQUIVALENCE statements.
|
|
|
999efc |
+!
|
|
|
999efc |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
999efc |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
999efc |
+!
|
|
|
999efc |
+ MODULE SEQ
|
|
|
999efc |
+ TYPE STRUCT1
|
|
|
999efc |
+ INTEGER*4 ID
|
|
|
999efc |
+ INTEGER*4 TYPE
|
|
|
999efc |
+ INTEGER*8 DEFVAL
|
|
|
999efc |
+ CHARACTER*(4) NAME
|
|
|
999efc |
+ LOGICAL*1 NIL
|
|
|
999efc |
+ END TYPE STRUCT1
|
|
|
999efc |
+ END MODULE
|
|
|
999efc |
+
|
|
|
999efc |
+ SUBROUTINE A
|
|
|
999efc |
+ USE SEQ
|
|
|
999efc |
+ TYPE (STRUCT1) S
|
|
|
999efc |
+ COMMON /BLOCK1/ S
|
|
|
999efc |
+ IF (S%ID.NE.5) STOP 1
|
|
|
999efc |
+ IF (S%TYPE.NE.1000) STOP 2
|
|
|
999efc |
+ IF (S%DEFVAL.NE.-99) STOP 3
|
|
|
999efc |
+ IF (S%NAME.NE."JANE") STOP 4
|
|
|
999efc |
+ IF (S%NIL.NEQV..FALSE.) STOP 5
|
|
|
999efc |
+ END SUBROUTINE
|
|
|
999efc |
+
|
|
|
999efc |
+ PROGRAM sequence_att_common
|
|
|
999efc |
+ USE SEQ
|
|
|
999efc |
+ IMPLICIT NONE
|
|
|
999efc |
+ TYPE (STRUCT1) S1
|
|
|
999efc |
+ TYPE (STRUCT1) S2
|
|
|
999efc |
+ TYPE (STRUCT1) S3
|
|
|
999efc |
+
|
|
|
999efc |
+ EQUIVALENCE (S1,S2)
|
|
|
999efc |
+ COMMON /BLOCK1/ S3
|
|
|
999efc |
+
|
|
|
999efc |
+ S1%ID = 5
|
|
|
999efc |
+ S1%TYPE = 1000
|
|
|
999efc |
+ S1%DEFVAL = -99
|
|
|
999efc |
+ S1%NAME = "JANE"
|
|
|
999efc |
+ S1%NIL = .FALSE.
|
|
|
999efc |
+
|
|
|
999efc |
+ IF (S2%ID.NE.5) STOP 1
|
|
|
999efc |
+ IF (S2%TYPE.NE.1000) STOP 2
|
|
|
999efc |
+ IF (S2%DEFVAL.NE.-99) STOP 3
|
|
|
999efc |
+ IF (S2%NAME.NE."JANE") STOP 4
|
|
|
999efc |
+ IF (S2%NIL.NEQV..FALSE.) STOP 5
|
|
|
999efc |
+
|
|
|
999efc |
+ S3 = S1
|
|
|
999efc |
+
|
|
|
999efc |
+ CALL A
|
|
|
999efc |
+
|
|
|
999efc |
+ END
|
|
|
999efc |
diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
|
|
|
999efc |
new file mode 100644
|
|
|
999efc |
index 00000000000..26cd59f9090
|
|
|
999efc |
--- /dev/null
|
|
|
999efc |
+++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default_3.f
|
|
|
999efc |
@@ -0,0 +1,57 @@
|
|
|
999efc |
+! { dg-do compile }
|
|
|
999efc |
+! { dg-options "-fdec -fno-dec-sequence" }
|
|
|
999efc |
+!
|
|
|
999efc |
+! Test add default SEQUENCE attribute derived types appearing in
|
|
|
999efc |
+! COMMON blocks and EQUIVALENCE statements.
|
|
|
999efc |
+!
|
|
|
999efc |
+! Contributed by Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
999efc |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
999efc |
+!
|
|
|
999efc |
+ MODULE SEQ
|
|
|
999efc |
+ TYPE STRUCT1
|
|
|
999efc |
+ INTEGER*4 ID
|
|
|
999efc |
+ INTEGER*4 TYPE
|
|
|
999efc |
+ INTEGER*8 DEFVAL
|
|
|
999efc |
+ CHARACTER*(4) NAME
|
|
|
999efc |
+ LOGICAL*1 NIL
|
|
|
999efc |
+ END TYPE STRUCT1
|
|
|
999efc |
+ END MODULE
|
|
|
999efc |
+
|
|
|
999efc |
+ SUBROUTINE A
|
|
|
999efc |
+ USE SEQ
|
|
|
999efc |
+ TYPE (STRUCT1) S ! { dg-error "Derived type variable" }
|
|
|
999efc |
+ COMMON /BLOCK1/ S
|
|
|
999efc |
+ IF (S%ID.NE.5) STOP 1
|
|
|
999efc |
+ IF (S%TYPE.NE.1000) STOP 2
|
|
|
999efc |
+ IF (S%DEFVAL.NE.-99) STOP 3
|
|
|
999efc |
+ IF (S%NAME.NE."JANE") STOP 4
|
|
|
999efc |
+ IF (S%NIL.NEQV..FALSE.) STOP 5
|
|
|
999efc |
+ END SUBROUTINE
|
|
|
999efc |
+
|
|
|
999efc |
+ PROGRAM sequence_att_common
|
|
|
999efc |
+ USE SEQ
|
|
|
999efc |
+ IMPLICIT NONE
|
|
|
999efc |
+ TYPE (STRUCT1) S1
|
|
|
999efc |
+ TYPE (STRUCT1) S2
|
|
|
999efc |
+ TYPE (STRUCT1) S3 ! { dg-error "Derived type variable" }
|
|
|
999efc |
+
|
|
|
999efc |
+ EQUIVALENCE (S1,S2) ! { dg-error "Derived type variable" }
|
|
|
999efc |
+ COMMON /BLOCK1/ S3
|
|
|
999efc |
+
|
|
|
999efc |
+ S1%ID = 5
|
|
|
999efc |
+ S1%TYPE = 1000
|
|
|
999efc |
+ S1%DEFVAL = -99
|
|
|
999efc |
+ S1%NAME = "JANE"
|
|
|
999efc |
+ S1%NIL = .FALSE.
|
|
|
999efc |
+
|
|
|
999efc |
+ IF (S2%ID.NE.5) STOP 1
|
|
|
999efc |
+ IF (S2%TYPE.NE.1000) STOP 2
|
|
|
999efc |
+ IF (S2%DEFVAL.NE.-99) STOP 3
|
|
|
999efc |
+ IF (S2%NAME.NE."JANE") STOP 4
|
|
|
999efc |
+ IF (S2%NIL.NEQV..FALSE.) STOP 5
|
|
|
999efc |
+
|
|
|
999efc |
+ S3 = S1
|
|
|
999efc |
+
|
|
|
999efc |
+ CALL A
|
|
|
999efc |
+
|
|
|
999efc |
+ END
|
|
|
999efc |
--
|
|
|
999efc |
2.11.0
|
|
|
999efc |
|