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