2008-01-06 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 6 Jan 2008 18:07:52 +0000 (18:07 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 6 Jan 2008 18:07:52 +0000 (18:07 +0000)
        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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131353 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/equiv_constraint_9.f90 [new file with mode: 0644]

index 2fccd48..a3d2ee8 100644 (file)
@@ -1,5 +1,11 @@
 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/34654
        * io.c (check_io_constraints): Disallow unformatted I/O for
        internal units.
index e4f7dcb..6cde79f 100644 (file)
@@ -8534,6 +8534,14 @@ resolve_equivalence_derived (gfc_symbol *derived, gfc_symbol *sym, gfc_expr *e)
       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 2b08e57..549a007 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-06  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34655
+       * gfortran.dg/equiv_constraint_9.f90: New.
+
 2008-01-06  Revital Eres  <eres@il.ibm.com>
 
        PR tree-optimization/34263
diff --git a/gcc/testsuite/gfortran.dg/equiv_constraint_9.f90 b/gcc/testsuite/gfortran.dg/equiv_constraint_9.f90
new file mode 100644 (file)
index 0000000..3374441
--- /dev/null
@@ -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) ! { dg-error "with default initializations cannot be in EQUIVALENCE with a variable in COMMON" }
+EQUIVALENCE(ff,k)
+EQUIVALENCE(gg,m)
+COMMON /COM/ j
+COMMON /COM/ m
+END