From dcd3d96354f9b1528a64b77050070aaa1f7a6d87 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Tue, 2 Oct 2007 11:45:11 +0000 Subject: re PR fortran/33542 (gfortran does not detect ambigious specific names if they are the same as generic names) 2007-10-02 Paul Thomas PR fortran/33542 * interface.c (check_interface1): Specific procedures are always ambiguous if they have the same name. 2007-10-02 Paul Thomas PR fortran/33542 * gfortran.dg/ambiguous_specific_1.f90: New test. From-SVN: r128954 --- gcc/fortran/ChangeLog | 6 ++++ gcc/fortran/interface.c | 3 +- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gfortran.dg/ambiguous_specific_1.f90 | 37 ++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/ambiguous_specific_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 49dec96..0d5c0cc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2007-10-02 Paul Thomas + PR fortran/33542 + * interface.c (check_interface1): Specific procedures are + always ambiguous if they have the same name. + +2007-10-02 Paul Thomas + PR fortran/33566 * primary.c (gfc_match_rvalue): Make all expressions with array references to structure parameters into variable expressions. diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 741bba5..6513517 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1044,7 +1044,8 @@ check_interface1 (gfc_interface *p, gfc_interface *q0, if (p->sym->name == q->sym->name && p->sym->module == q->sym->module) continue; - if (compare_interfaces (p->sym, q->sym, generic_flag)) + if (compare_interfaces (p->sym, q->sym, generic_flag) + || p->sym->name == q->sym->name) { if (referenced) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a28ce7b..b3fb374 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-10-02 Paul Thomas + + PR fortran/33542 + * gfortran.dg/ambiguous_specific_1.f90: New test. + 2007-10-02 Revital Eres * gcc.target/powerpc/paired-8.c: New test. diff --git a/gcc/testsuite/gfortran.dg/ambiguous_specific_1.f90 b/gcc/testsuite/gfortran.dg/ambiguous_specific_1.f90 new file mode 100644 index 0000000..63ea9da --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ambiguous_specific_1.f90 @@ -0,0 +1,37 @@ +! { dg-do compile } +! Checks the fix for PR33542, in which the ambiguity in the specific +! interfaces of foo was missed. +! +! Contributed by Tobias Burnus +! +MODULE M1 + INTERFACE FOO + MODULE PROCEDURE FOO2 + END INTERFACE +CONTAINS + SUBROUTINE FOO2(I) + INTEGER, INTENT(IN) :: I + WRITE(*,*) 'INTEGER' + END SUBROUTINE FOO2 +END MODULE M1 + +MODULE M2 + INTERFACE FOO + MODULE PROCEDURE FOO2 + END INTERFACE +CONTAINS + SUBROUTINE FOO2(R) + REAL, INTENT(IN) :: R + WRITE(*,*) 'REAL' + END SUBROUTINE FOO2 +END MODULE M2 + +PROGRAM P + USE M1 ! { dg-error "Ambiguous interfaces" } + USE M2 + implicit none + external bar + CALL FOO(10) + CALL FOO(10.) +END PROGRAM P +! { dg-final { cleanup-modules "m1 m2" } } -- cgit v1.1