|
|
3db796 |
From fdda38024c7151ca632cb338085af80ceb63ec4d Mon Sep 17 00:00:00 2001
|
|
|
3db796 |
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
|
|
|
3db796 |
Date: Wed, 18 Nov 2015 15:08:56 +0000
|
|
|
3db796 |
Subject: [PATCH 17/23] Add the SEQUENCE attribute by default if it's not
|
|
|
3db796 |
present.
|
|
|
3db796 |
|
|
|
3db796 |
This feature is enabled by the `-std=extra-legacy` compiler flag.
|
|
|
3db796 |
|
|
|
3db796 |
|
|
|
3db796 |
0017-Add-the-SEQUENCE-attribute-by-default-if-it-s-not-pr.patch
|
|
|
3db796 |
|
|
|
6068c7 |
commit 1635277d719de05fbd37a2887273ce893bf43198
|
|
|
6068c7 |
Author: Jim MacArthur <jim.macarthur@codethink.co.uk>
|
|
|
6068c7 |
Date: Wed Nov 18 15:08:56 2015 +0000
|
|
|
6068c7 |
|
|
|
6068c7 |
Add the SEQUENCE attribute by default if it's not present.
|
|
|
6068c7 |
|
|
|
6068c7 |
This feature is enabled by the `-std=extra-legacy` compiler flag.
|
|
|
6068c7 |
|
|
|
6068c7 |
Test written by: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
|
|
|
6068c7 |
|
|
|
3db796 |
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
|
|
|
6068c7 |
index 2e60984b3bd..022b9230ec9 100644
|
|
|
3db796 |
--- a/gcc/fortran/resolve.c
|
|
|
3db796 |
+++ b/gcc/fortran/resolve.c
|
|
|
3db796 |
@@ -963,9 +963,16 @@ resolve_common_vars (gfc_common_head *common_block, bool named_common)
|
|
|
3db796 |
|
|
|
3db796 |
if (!(csym->ts.u.derived->attr.sequence
|
|
|
3db796 |
|| csym->ts.u.derived->attr.is_bind_c))
|
|
|
3db796 |
- gfc_error_now ("Derived type variable %qs in COMMON at %L "
|
|
|
3db796 |
- "has neither the SEQUENCE nor the BIND(C) "
|
|
|
3db796 |
- "attribute", csym->name, &csym->declared_at);
|
|
|
3db796 |
+ {
|
|
|
3db796 |
+ if (gfc_option.allow_std & GFC_STD_EXTRA_LEGACY)
|
|
|
3db796 |
+ /* Assume sequence. */
|
|
|
3db796 |
+ csym->ts.u.derived->attr.sequence = 1;
|
|
|
3db796 |
+ else
|
|
|
3db796 |
+ gfc_error_now ("Derived type variable '%s' in COMMON at %L "
|
|
|
3db796 |
+ "has neither the SEQUENCE nor the BIND(C) "
|
|
|
3db796 |
+ "attribute", csym->name, &csym->declared_at);
|
|
|
3db796 |
+ }
|
|
|
3db796 |
+
|
|
|
3db796 |
if (csym->ts.u.derived->attr.alloc_comp)
|
|
|
3db796 |
gfc_error_now ("Derived type variable %qs in COMMON at %L "
|
|
|
3db796 |
"has an ultimate component that is "
|
|
|
6068c7 |
diff --git a/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default.f b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default.f
|
|
|
6068c7 |
new file mode 100644
|
|
|
6068c7 |
index 00000000000..c0851c8bc77
|
|
|
6068c7 |
--- /dev/null
|
|
|
6068c7 |
+++ b/gcc/testsuite/gfortran.dg/dec_add_SEQUENCE_to_COMMON_block_by_default.f
|
|
|
6068c7 |
@@ -0,0 +1,17 @@
|
|
|
6068c7 |
+! { dg-do compile }
|
|
|
6068c7 |
+! { dg-options "-std=extra-legacy" }
|
|
|
6068c7 |
+!
|
|
|
6068c7 |
+! Test add default SEQUENCE attribute to COMMON blocks
|
|
|
6068c7 |
+!
|
|
|
6068c7 |
+ PROGRAM sequence_att_common
|
|
|
6068c7 |
+ TYPE STRUCT1
|
|
|
6068c7 |
+ INTEGER*4 ID
|
|
|
6068c7 |
+ INTEGER*4 TYPE
|
|
|
6068c7 |
+ INTEGER*8 DEFVAL
|
|
|
6068c7 |
+ CHARACTER*(4) NAME
|
|
|
6068c7 |
+ LOGICAL*1 NIL
|
|
|
6068c7 |
+ END TYPE STRUCT1
|
|
|
6068c7 |
+
|
|
|
6068c7 |
+ TYPE (STRUCT1) SINST
|
|
|
6068c7 |
+ COMMON /BLOCK1/ SINST
|
|
|
6068c7 |
+ END
|