From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9002 invoked by alias); 29 Oct 2010 16:01:23 -0000 Received: (qmail 8986 invoked by uid 22791); 29 Oct 2010 16:01:21 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID,TW_CS X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Oct 2010 16:01:15 +0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46196] [OOP] gfortran compiles invalid generic TBP: dummy arguments are type compatible X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: janus at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 29 Oct 2010 16:01:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg02501.txt.bz2 Message-ID: <20101029160100.qso5jcLnk5tq4AAzZX9CUrMOPWUsWoF1Zg0S89zbf8k@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46196 Dominique d'Humieres changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus@net-b.de --- Comment #8 from Dominique d'Humieres 2010-10-29 16:00:57 UTC --- I have successfully regtested the following patch, i.e., the patch in comment #2 and the fix for the typos reported in comment #5, on top of revision 166058 (plus a few unrelated patches). I also noticed that the fix for pr46067 use the asymmetry of gfc_compare_interfaces!-) ------------------------------------------------------------------------ --- ../_clean/gcc/fortran/interface.c 2010-10-27 23:47:20.000000000 +0200 +++ gcc/fortran/interface.c 2010-10-29 10:55:07.000000000 +0200 @@ -445,16 +445,16 @@ gfc_compare_derived_types (gfc_symbol *d /* Make sure that link lists do not put this function into an endless recursive loop! */ if (!(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived) - && !(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived) + && !(dt2->ts.type == BT_DERIVED && derived2 == dt2->ts.u.derived) && gfc_compare_types (&dt1->ts, &dt2->ts) == 0) return 0; else if ((dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived) - && !(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived)) + && !(dt2->ts.type == BT_DERIVED && derived2 == dt2->ts.u.derived)) return 0; else if (!(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived) - && (dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived)) + && (dt2->ts.type == BT_DERIVED && derived2 == dt2->ts.u.derived)) return 0; dt1 = dt1->next; @@ -872,7 +872,8 @@ count_types_test (gfc_formal_arglist *f1 /* Find other nonoptional arguments of the same type/rank. */ for (j = i + 1; j < n1; j++) if ((arg[j].sym == NULL || !arg[j].sym->attr.optional) - && compare_type_rank_if (arg[i].sym, arg[j].sym)) + && (compare_type_rank_if (arg[i].sym, arg[j].sym) + || compare_type_rank_if (arg[j].sym, arg[i].sym))) arg[j].flag = k; k++; @@ -897,7 +898,8 @@ count_types_test (gfc_formal_arglist *f1 ac2 = 0; for (f = f2; f; f = f->next) - if (compare_type_rank_if (arg[i].sym, f->sym)) + if (compare_type_rank_if (arg[i].sym, f->sym) + || compare_type_rank_if (f->sym, arg[i].sym)) ac2++; if (ac1 > ac2) @@ -948,7 +950,8 @@ generic_correspondence (gfc_formal_argli if (f1->sym->attr.optional) goto next; - if (f2 != NULL && compare_type_rank (f1->sym, f2->sym)) + if (f2 != NULL && (compare_type_rank (f1->sym, f2->sym) + || compare_type_rank (f2->sym, f1->sym))) goto next; /* Now search for a disambiguating keyword argument starting at ------------------------------------------------------------------------ This has disturbed my bug collection for the following tests: *Code in (1) pr41951_3.f90:21.32: generic :: operator(.gt.) => gt_cmp_int 1 Error: 'gt_cmp_int' and 'gt_cmp' for GENERIC '.gt.' at (1) are ambiguous *Code in comment #24 pr42274_5.f90:14.33: generic, public :: extract => make_integer_2 1 Error: 'make_integer_2' and 'make_integer' for GENERIC 'extract' at (1) are ambiguous *Code in comment #0 with !!$ removed pr43945_2.f90:30.29: generic, public :: do => doit 1 Error: 'doit2' and 'doit' for GENERIC 'do' at (1) are ambiguous pr43945_2.f90:31.29: generic, public :: get => getit 1 Error: 'getit2' and 'getit' for GENERIC 'get' at (1) are ambiguous *Expected pr44917.f90, pr44917_1.f90, oop.f90 oop.f90:22.33: generic, public :: extract => real, make_integer_2 1 Error: 'make_integer_2' and 'make_integer' for GENERIC 'extract' at (1) are ambiguous *Expected pr44926.f90:33.35: generic, public :: csget => d_get 1 Error: 'd_get' and 'base_csgetp' for GENERIC 'csget' at (1) are ambiguous *Expected pr46196.f90:9.24: generic :: g_sub => a_subroutine,b_subroutine 1 Error: 'a_subroutine' and 'b_subroutine' for GENERIC 'g_sub' at (1) are ambiguous ------------------------------------------------------------------------ (1) code for pr41951_3.f90: module m_sort implicit none type, abstract :: sort_t contains generic :: operator(.gt.) => gt_cmp procedure :: gt_cmp end type sort_t contains logical function gt_cmp(a,b) class(sort_t), intent(in) :: a, b gt_cmp = .true. end function gt_cmp end module module test use m_sort implicit none type, extends(sort_t) :: sort_int_t integer :: i contains generic :: operator(.gt.) => gt_cmp_int procedure :: gt_cmp_int end type contains logical function gt_cmp_int(a,b) result(cmp) class(sort_int_t), intent(in) :: a, b if (a%i > b%i) then cmp = .true. else cmp = .false. end if end function gt_cmp_int end module end I am pretty bad with such ambiguous stuff, especially with classes, so I let the experts check that there is no false positive.