This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran] PR34655 - default init and equiv association with COMMON variable
- From: Tobias Burnus <burnus at net-b dot de>
- To: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 06 Jan 2008 18:43:02 +0100
- Subject: [Patch, Fortran] PR34655 - default init and equiv association with COMMON variable
"5.5.2.5 Restrictions on common and equivalence"
"Equivalence association shall not cause a derived-t 1 ype object with
default initialization to be associated with an object in a common block."
Build and regtested on x86-64-linux.
OK for the trunk?
Tobias
2008-01-06 Tobias Burnus <burnus@net-b.de>
PR fortran/34655
* resolve.c (resolve_equivalence_derived): Reject derived types with
default initialization if equivalenced with COMMON variable.
2008-01-06 Tobias Burnus <burnus@net-b.de>
PR fortran/34655
* gfortran.dg/equiv_constraint_9.f90: New.
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (Revision 131350)
+++ gcc/fortran/resolve.c (Arbeitskopie)
@@ -8534,6 +8560,14 @@ resolve_equivalence_derived (gfc_symbol
return FAILURE;
}
+ if (sym->attr.in_common && has_default_initializer (sym->ts.derived))
+ {
+ gfc_error ("Derived type variable '%s' at %L with default "
+ "initialization cannot be in EQUIVALENCE with a variable "
+ "in COMMON", sym->name, &e->where);
+ return FAILURE;
+ }
+
for (; c ; c = c->next)
{
d = c->ts.derived;
Index: gcc/testsuite/gfortran.dg/equiv_constraint_9.f90
===================================================================
--- gcc/testsuite/gfortran.dg/equiv_constraint_9.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/equiv_constraint_9.f90 (Revision 0)
@@ -0,0 +1,28 @@
+! { dg-do compile }
+!
+! PR fortran/34655
+!
+! Check for F2003's 5.5.2.5 Restrictions on common and equivalence
+! Test case contributed by Joost VandeVondele.
+!
+implicit none
+type data_type
+ sequence
+ integer :: I = 7
+end type data_type
+
+
+type data_type2
+ sequence
+ integer :: I
+end type data_type2
+
+type(data_type) :: dd, ff
+type(data_type2) :: gg
+integer :: j, k, m
+EQUIVALENCE(dd,J)
+EQUIVALENCE(ff,k) ! { dg-error "with default initializations cannot be in EQUIVALENCE with a variable in COMMON" }
+EQUIVALENCE(gg,m)
+COMMON /COM/ j
+COMMON /COM/ m
+END