Blame SOURCES/0017-Add-the-SEQUENCE-attribute-by-default-if-it-s-not-pr.patch

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