From cddcf0d4aeef26fad7185ec9ba79adc23f78739c Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sun, 6 Jan 2008 19:07:52 +0100 Subject: [PATCH] re PR fortran/34655 (5.5.2.5) 2008-01-06 Tobias Burnus PR fortran/34655 * resolve.c (resolve_equivalence_derived): Reject derived types * with default initialization if equivalenced with COMMON variable. 2008-01-06 Tobias Burnus PR fortran/34655 * gfortran.dg/equiv_constraint_9.f90: New. From-SVN: r131353 --- gcc/fortran/ChangeLog | 6 ++++ gcc/fortran/resolve.c | 8 ++++++ gcc/testsuite/ChangeLog | 5 ++++ .../gfortran.dg/equiv_constraint_9.f90 | 28 +++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/equiv_constraint_9.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2fccd4862f80..a3d2ee8fe717 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2008-01-06 Tobias Burnus + + PR fortran/34655 + * resolve.c (resolve_equivalence_derived): Reject derived types with + default initialization if equivalenced with COMMON variable. + 2008-01-06 Tobias Burnus PR fortran/34654 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index e4f7dcbac4aa..6cde79fb7556 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2b08e5793e2a..549a0074f6b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-06 Tobias Burnus + + PR fortran/34655 + * gfortran.dg/equiv_constraint_9.f90: New. + 2008-01-06 Revital Eres 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 index 000000000000..337444140111 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/equiv_constraint_9.f90 @@ -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 -- 2.43.5