From 6ba84c3143a13266f40ea804ae2fb98717ccfc04 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 4 May 2012 20:53:17 +0200 Subject: [PATCH] re PR fortran/53111 (Derived types cannot be USE-associated again with -std=f95) 2012-05-04 Tobias Burnus PR fortran/53111 * resolve.c (resolve_fl_derived): Fix -std=f95 diagnostic for generic vs. DT names. 2012-05-04 Tobias Burnus PR fortran/53111 * gfortran.dg/constructor_7.f90: New. * gfortran.dg/constructor_8.f90: New. From-SVN: r187174 --- gcc/fortran/ChangeLog | 6 +++ gcc/fortran/resolve.c | 2 + gcc/testsuite/ChangeLog | 20 ++++++--- gcc/testsuite/gfortran.dg/constructor_7.f90 | 48 +++++++++++++++++++++ gcc/testsuite/gfortran.dg/constructor_8.f90 | 22 ++++++++++ 5 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/constructor_7.f90 create mode 100644 gcc/testsuite/gfortran.dg/constructor_8.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 56626518e50..0965b00bc10 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-05-04 Tobias Burnus + + PR fortran/53111 + * resolve.c (resolve_fl_derived): Fix -std=f95 + diagnostic for generic vs. DT names. + 2012-05-03 Tobias Burnus PR fortran/52864 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 57da577dfaa..411ebb5a1c2 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -12015,6 +12015,8 @@ resolve_fl_derived (gfc_symbol *sym) if (!sym->attr.is_class) gfc_find_symbol (sym->name, sym->ns, 0, &gen_dt); if (gen_dt && gen_dt->generic && gen_dt->generic->next + && (!gen_dt->generic->sym->attr.use_assoc + || gen_dt->generic->sym->module != gen_dt->generic->next->sym->module) && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Generic name '%s' of " "function '%s' at %L being the same name as derived " "type at %L", sym->name, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4468854c464..c3e7db777f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-05-04 Tobias Burnus + + PR fortran/53111 + * gfortran.dg/constructor_7.f90: New. + * gfortran.dg/constructor_8.f90: New. + 2012-05-04 Paolo Carlini PR c++/53166 @@ -92,10 +98,10 @@ 2012-05-03 Greta Yorsh - * gcc.dg/fixed-point/composite-type.c (dg-options): Add - option -ftrack-macro-expansion=0. - * gcc.dg/fixed-point/operator-bitwise.c (dg-options): Add - option -ftrack-macro-expansion=0. + * gcc.dg/fixed-point/composite-type.c (dg-options): Add + option -ftrack-macro-expansion=0. + * gcc.dg/fixed-point/operator-bitwise.c (dg-options): Add + option -ftrack-macro-expansion=0. 2012-05-03 Greta Yorsh @@ -260,11 +266,11 @@ Fix expansion point loc for macro-like tokens * gcc.dg/debug/dwarf2/pr41445-5.c: Adjust. - * gcc.dg/debug/dwarf2/pr41445-6.c: Likewise. + * gcc.dg/debug/dwarf2/pr41445-6.c: Likewise. Fix token pasting with -ftrack-macro-expansion * gcc.dg/cpp/paste17.c: New test case for - -ftrack-macro-expansion=2 mode only. + -ftrack-macro-expansion=2 mode only. * gcc.dg/cpp/macro-exp-tracking-5.c: Likewise. 2012-04-30 Eric Botcazou @@ -274,7 +280,7 @@ 2012-04-29 Manuel López-Ibáñez PR 53149 - * gcc.dg/20011021-1.c: Adjust testcase. + * gcc.dg/20011021-1.c: Adjust testcase. 2012-04-29 Thomas Koenig diff --git a/gcc/testsuite/gfortran.dg/constructor_7.f90 b/gcc/testsuite/gfortran.dg/constructor_7.f90 new file mode 100644 index 00000000000..f3d6605a34c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/constructor_7.f90 @@ -0,0 +1,48 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! +! PR fortran/53111 +! + +! ------------ INVALID ONE ------------------------ + +module m +type t + integer :: i +end type t +end + +module m2 + interface t + module procedure sub + end interface t +contains + integer function sub() + sub = 4 + end function sub +end module m2 + +! Note: The following is formally valid as long as "t" is not used. +! For simplicity, -std=f95 will give an error. +! It is unlikely that a real-world program is rejected with -std=f95 +! because of that. + +use m ! { dg-error "Fortran 2003: Generic name 't' of function 'sub' at .1. being the same name as derived type at" } +use m2 ! { dg-error "Fortran 2003: Generic name 't' of function 'sub' at .1. being the same name as derived type at" } +! i = sub() ! << Truly invalid in F95, valid in F2003 +end + +! ------------ INVALID TWO ------------------------ + +module m3 +type t2 ! { dg-error "Fortran 2003: Generic name 't2' of function 'sub2' at .1. being the same name as derived type at" } + integer :: i +end type t2 + interface t2 + module procedure sub2 + end interface t2 +contains + integer function sub2() ! { dg-error "Fortran 2003: Generic name 't2' of function 'sub2' at .1. being the same name as derived type at" } + sub2 = 4 + end function sub2 +end module m3 diff --git a/gcc/testsuite/gfortran.dg/constructor_8.f90 b/gcc/testsuite/gfortran.dg/constructor_8.f90 new file mode 100644 index 00000000000..ff0dff7b868 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/constructor_8.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! +! PR fortran/53111 +! +! Contributed by Jacob Middag, reduced by Janus Weil. +! + +module a + type :: my + real :: x + end type +end module + +module b + use a +end module + +program test + use a + use b +end program -- 2.30.2