[Patch, fortran] PR29652 -
Paul Thomas
paulthomas2@wanadoo.fr
Fri Nov 17 20:09:00 GMT 2006
Ping to somebody other than Steve - this one is really easy.
Paul
> Sorry about this - I seem to be all thumbs tonight. The title line
> should be
>
> [Patch, fortran] PR29652 - ambiguous interface declaration undetected
>> :ADDPATCH fortran:
>>
>> This represents my second contribution in a struggle with the
>> interface meta-bug PR29670.
>>
>> This patch corrects a coding error in check_interface1, which
>> compares two interface lists. The arguments were used as the
>> iterators for both and, as a result, the inner one was never reset.
>> Thus there would only be one passage through the inner list for the
>> the first symbol in the outer. The fix is, of course, to reset the
>> inner iterator and to use a local pointer for it. The testcase
>> exercises the original PR, which is associated with a generic
>> interface. gfortran.dg/defined_operatos_1.f90 had to be modified
>> because one of the user-defined operator interfaces is now detected
>> to be ambiguous; his seems like an economical test of this case.
>>
>> Regtested on Cygwin_NT/amd64 - OK for trunk, 4.2 and 4.1?
>>
>> Paul
>>
>> 2006-11-15 Paul Thomas <pault@gcc.gnu.org>
>>
>> PR fortran/29652
>> * interface.c (check_interface1): Use a local value, instead of
>> the dummy, as
>> the inner iterator over interface symbols.
>>
>> 2006-11-15 Paul Thomas <pault@gcc.gnu.org>
>>
>> PR fortran/29652
>> * gfortran.dg/generic_7.f90: New test.
>> * gfortran.dg/defined_operators_1.f90: Add new error.
>> ------------------------------------------------------------------------
>>
>> Index: gcc/fortran/interface.c
>> ===================================================================
>> *** gcc/fortran/interface.c (revision 118704)
>> --- gcc/fortran/interface.c (working copy)
>> *************** check_interface0 (gfc_interface * p, con
>> *** 964,975 ****
>> here. */
>> static int
>> ! check_interface1 (gfc_interface * p, gfc_interface * q,
>> int generic_flag, const char *interface_name)
>> {
>> ! for (; p; p = p->next)
>> ! for (; q; q = q->next)
>> {
>> if (p->sym == q->sym)
>> continue; /* Duplicates OK here */
>> --- 964,975 ----
>> here. */
>> static int
>> ! check_interface1 (gfc_interface * p, gfc_interface * q0,
>> int generic_flag, const char *interface_name)
>> {
>> ! gfc_interface * q;
>> for (; p; p = p->next)
>> ! for (q = q0; q; q = q->next)
>> {
>> if (p->sym == q->sym)
>> continue; /* Duplicates OK here */
>> Index: gcc/testsuite/gfortran.dg/generic_7.f90
>> ===================================================================
>> *** gcc/testsuite/gfortran.dg/generic_7.f90 (revision 0)
>> --- gcc/testsuite/gfortran.dg/generic_7.f90 (revision 0)
>> ***************
>> *** 0 ****
>> --- 1,27 ----
>> + ! { dg-do compile }
>> + ! Tests the fix for PR29652, in which ambiguous interfaces were not
>> detected
>> + ! with more than two specific procedures in the interface.
>> + !
>> + ! Contributed by Daniel Franke <franke.daniel@gmail.com>
>> + !
>> + MODULE global
>> + INTERFACE iface
>> + MODULE PROCEDURE sub_a
>> + MODULE PROCEDURE sub_b ! { dg-error "Ambiguous interfaces" }
>> + MODULE PROCEDURE sub_c
>> + END INTERFACE
>> + CONTAINS
>> + SUBROUTINE sub_a(x)
>> + INTEGER, INTENT(in) :: x
>> + WRITE (*,*) 'A: ', x
>> + END SUBROUTINE
>> + SUBROUTINE sub_b(y)
>> + INTEGER, INTENT(in) :: y
>> + WRITE (*,*) 'B: ', y
>> + END SUBROUTINE
>> + SUBROUTINE sub_c(x, y)
>> + REAL, INTENT(in) :: x, y
>> + WRITE(*,*) x, y
>> + END SUBROUTINE
>> + END MODULE
>> + ! { dg-final { cleanup-modules "global" } }
>> Index: gcc/testsuite/gfortran.dg/defined_operators_1.f90
>> ===================================================================
>> *** gcc/testsuite/gfortran.dg/defined_operators_1.f90 (revision
>> 118704)
>> --- gcc/testsuite/gfortran.dg/defined_operators_1.f90 (working copy)
>> *************** module mymod
>> *** 11,17 ****
>> module procedure foo_1 ! { dg-error "must be INTENT" }
>> module procedure foo_2 ! { dg-error "cannot be optional" }
>> module procedure foo_3 ! { dg-error "must have, at most, two
>> arguments" }
>> ! module procedure foo_1_OK
>> module procedure foo_2_OK
>> function foo_chr (chr) ! { dg-error "cannot be assumed
>> character length" }
>> character(*) :: foo_chr
>> --- 11,17 ----
>> module procedure foo_1 ! { dg-error "must be INTENT" }
>> module procedure foo_2 ! { dg-error "cannot be optional" }
>> module procedure foo_3 ! { dg-error "must have, at most, two
>> arguments" }
>> ! module procedure foo_1_OK ! { dg-error "Ambiguous interfaces" }
>> module procedure foo_2_OK
>> function foo_chr (chr) ! { dg-error "cannot be assumed
>> character length" }
>> character(*) :: foo_chr
>>
>
>
>
More information about the Fortran
mailing list