From patchwork Sun Aug 5 13:23:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 953525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483190-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uPGybXdR"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41k1jX4fwBz9s0R for ; Sun, 5 Aug 2018 23:25:01 +1000 (AEST) Received: (qmail 104187 invoked by alias); 5 Aug 2018 13:24:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 103908 invoked by uid 89); 5 Aug 2018 13:24:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw1-f44.google.com Received: from mail-yw1-f44.google.com (HELO mail-yw1-f44.google.com) (209.85.161.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 Aug 2018 13:24:02 +0000 Received: by mail-yw1-f44.google.com with SMTP id t18-v6so2663107ywg.2; Sun, 05 Aug 2018 06:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=ojwJA7jPML7lNwsLoLbeaIVVfEmZqwnbvde8ID1o47E=; b=uPGybXdRy7H0fLY2bbN9mDxpSHjRdON7dDhZIvoJkGbrnfWDPDz1Ug+xd5oBd+X0fr obn9NM9CssHJKqY6fT8OmldKTTezqm3jhDpAZWPqF2mgWHeTOEpEdsVGh0aBTOJjOvJi E4y5FjJwh8KflttQjs3ng9Az140z1SozEpKyuODmy2vgkdx8/wdZvNQN2Qi6hdyAQO9F ZBG2+JOo35ZpLZBj+TRFqNxaLR6Zy5giU680CELLADs2XBozprQURvXGEoyXSfvNyfvK P2NebtRAprRpr6xddd86HGfa6N66uyEUdyNb6Hq32QblLbu6OuNWRXOxad8Mi1Iaupz+ xUqA== MIME-Version: 1.0 Sender: jaydub66@gmail.com Received: by 2002:a0d:ea0c:0:0:0:0:0 with HTTP; Sun, 5 Aug 2018 06:23:59 -0700 (PDT) From: Janus Weil Date: Sun, 5 Aug 2018 15:23:59 +0200 Message-ID: Subject: [Patch, Fortran] PR 86116: Ambiguous generic interface not recognised To: gfortran , gcc-patches Hi all, the attached patch fixes PR 86116 by splitting up the function 'compare_type' into two variants: One that is used for checking generic interfaces and operators (keeping the old name), and one that is used for checking dummy functions and procedure pointer assignments ('compare_type_characteristics'). The latter calls the former, but includes an additional check that must not be done when checking generics. Regtests cleanly on x86_64-linux-gnu. Ok for trunk? Cheers, Janus 2018-08-05 Janus Weil PR fortran/86116 * interface.c (compare_type): Remove a CLASS/TYPE check. (compare_type_characteristics): New function that behaves like the old 'compare_type'. (gfc_check_dummy_characteristics, gfc_check_result_characteristics): Call 'compare_type_characteristics' instead of 'compare_type'. 2018-08-05 Janus Weil PR fortran/86116 * gfortran.dg/generic_34.f90: New test case. Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (revision 263308) +++ gcc/fortran/interface.c (working copy) @@ -735,6 +735,13 @@ compare_type (gfc_symbol *s1, gfc_symbol *s2) if (s2->attr.ext_attr & (1 << EXT_ATTR_NO_ARG_CHECK)) return true; + return gfc_compare_types (&s1->ts, &s2->ts) || s2->ts.type == BT_ASSUMED; +} + + +static bool +compare_type_characteristics (gfc_symbol *s1, gfc_symbol *s2) +{ /* TYPE and CLASS of the same declared type are type compatible, but have different characteristics. */ if ((s1->ts.type == BT_CLASS && s2->ts.type == BT_DERIVED) @@ -741,7 +748,7 @@ compare_type (gfc_symbol *s1, gfc_symbol *s2) || (s1->ts.type == BT_DERIVED && s2->ts.type == BT_CLASS)) return false; - return gfc_compare_types (&s1->ts, &s2->ts) || s2->ts.type == BT_ASSUMED; + return compare_type (s1, s2); } @@ -1309,7 +1316,8 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, g /* Check type and rank. */ if (type_must_agree) { - if (!compare_type (s1, s2) || !compare_type (s2, s1)) + if (!compare_type_characteristics (s1, s2) + || !compare_type_characteristics (s2, s1)) { snprintf (errmsg, err_len, "Type mismatch in argument '%s' (%s/%s)", s1->name, gfc_typename (&s1->ts), gfc_typename (&s2->ts)); @@ -1528,7 +1536,7 @@ gfc_check_result_characteristics (gfc_symbol *s1, return true; /* Check type and rank. */ - if (!compare_type (r1, r2)) + if (!compare_type_characteristics (r1, r2)) { snprintf (errmsg, err_len, "Type mismatch in function result (%s/%s)", gfc_typename (&r1->ts), gfc_typename (&r2->ts));