From patchwork Mon Jun 11 15:05:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 927731 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-479458-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=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="T4SHQyyg"; 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 414GXy1Z6Fz9ryk for ; Tue, 12 Jun 2018 01:05:36 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=LFMoq4xmZR3LHkhaWw1DdiIcXAtEX07auqCWW/2iXMOmeK O9xZq7totzMyiwLgGEVxK+00OaNZ6RNEMP8386e3vY9uQ7y1UfsOsMCgvgfYd38x FXXGEBpSgovw7vCdQX97MXIELTi9skaWdkOECAmrKIYXRyoczzitcsnjxLxFI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=uEb1re0czylxkcLSIXc4wgIg/k4=; b=T4SHQyygkBF08pI6vD6c NRYho6G3IrW+OS8gL/Cd4u2ar6ESOS5xNwvyFheexYkHqo1sJDzrEC26k7hr102Y 9aWl1Xszvlt+7IkXK3t766iXKaL8rdntVNEkmPivEuf/xWCOouLB77Rk6/DR8pdV O+oQ65TEHTofWb87LYpde1k= Received: (qmail 9647 invoked by alias); 11 Jun 2018 15:05: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 9141 invoked by uid 89); 11 Jun 2018 15:05:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 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=correspondence, tstype, UD:ts.type, UD:type X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yw0-f170.google.com Received: from mail-yw0-f170.google.com (HELO mail-yw0-f170.google.com) (209.85.161.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Jun 2018 15:05:20 +0000 Received: by mail-yw0-f170.google.com with SMTP id q7-v6so6404896ywd.9; Mon, 11 Jun 2018 08:05:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=GhJbQ+ZzUGKOy4ueIS7PUuuPUM8c9PzAgNc5W6SzDac=; b=XC87uUmqJ4ewIcyLMsZPHiVJ48S/Y4Wl+oYewv4EQYCBLKKTZdHkH5xiMYQOo0Jn+r seH14v1i/IIbSlx7vC75Q/7SuswzGDNrDwkAq4RDs445pA2sf4X3olS/vaWxiBb7iT3s DoFcUsixnOz2sA+A6+I8kNfN42kgYTcCzEvgJYGNgkwJw8BaonxuUGI4P7tkWXwWO6oY VxgqeWsz07UNlvClorodGnFh0hfbJ9jOPyX2V4ejIC50J0RLhKGD9J7CJU4p613UvEQc zbHznlbqZkUOotpCoP9UZs4pfyGkMXVEtsrc05ZGP6PJ1eFDSyFPBDDkLFtpe9Q1Gs7c xa9w== X-Gm-Message-State: APt69E0ainu67RxpF0VgXeBHObFwcV0wUR8WWjh7yWRuDWFhYYAERpwx GakpKgzMlHTuLseBLFTG3q2aeBbLx7cws6xW0Q3W9g== X-Google-Smtp-Source: ADUXVKIE+zqHMi7w/q7oMcuh+fIk/Wnj7vrdQLlrkHYLXZI5oYbsilzCgpUrJ/EYnSUpgPi7LxIYn+nRjbCrKHJU6Lg= X-Received: by 2002:a81:5590:: with SMTP id j138-v6mr10108286ywb.310.1528729518467; Mon, 11 Jun 2018 08:05:18 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a81:71d4:0:0:0:0:0 with HTTP; Mon, 11 Jun 2018 08:05:17 -0700 (PDT) From: Janus Weil Date: Mon, 11 Jun 2018 17:05:17 +0200 Message-ID: Subject: [Patch, Fortran, F08] PR 45521: GENERIC resolution with ALLOCATABLE/POINTER and PROCEDURE To: gfortran , gcc-patches Hi all, the attached patch fixes two remaining problems with the resolution of generic functions with POINTER and ALLOCATABLE arguments in F08 (coments 16 & 17 in the PR): * it deals with an INTENT(IN) condition that was added in an IR * it deals with polymorphic arguments, which were mistreated previously. The patch regtests cleanly on x86_64-linux-gnu. Ok for trunk? Cheers, Janus 2018-06-11 Janus Weil PR fortran/45521 * interface.c (compare_ptr_alloc): New function. (compare_ptr_alloc): Call it. 2018-06-11 Janus Weil PR fortran/45521 * gfortran.dg/generic_32.f90: New test. * gfortran.dg/generic_33.f90: New test. Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (revision 261393) +++ gcc/fortran/interface.c (working copy) @@ -1190,6 +1190,24 @@ } +/* Returns true if two dummy arguments are distinguishable due to their POINTER + and ALLOCATABLE attributes according to F2018 section 15.4.3.4.5 (3). + The function is asymmetric wrt to the arguments s1 and s2 and should always + be called twice (with flipped arguments in the second call). */ + +static bool +compare_ptr_alloc(gfc_symbol *s1, gfc_symbol *s2) +{ + /* Is s1 allocatable? */ + const bool a1 = s1->ts.type == BT_CLASS ? + CLASS_DATA(s1)->attr.allocatable : s1->attr.allocatable; + /* Is s2 a pointer? */ + const bool p2 = s2->ts.type == BT_CLASS ? + CLASS_DATA(s2)->attr.class_pointer : s2->attr.pointer; + return a1 && p2 && (s2->attr.intent != INTENT_IN); +} + + /* Perform the correspondence test in rule (3) of F08:C1215. Returns zero if no argument is found that satisfies this rule, nonzero otherwise. 'p1' and 'p2' are the PASS arguments of both procedures @@ -1233,8 +1251,8 @@ if (f2 != NULL && (compare_type_rank (f1->sym, f2->sym) || compare_type_rank (f2->sym, f1->sym)) && !((gfc_option.allow_std & GFC_STD_F2008) - && ((f1->sym->attr.allocatable && f2->sym->attr.pointer) - || (f2->sym->attr.allocatable && f1->sym->attr.pointer)))) + && (compare_ptr_alloc(f1->sym, f2->sym) + || compare_ptr_alloc(f2->sym, f1->sym)))) goto next; /* Now search for a disambiguating keyword argument starting at @@ -1247,8 +1265,8 @@ sym = find_keyword_arg (g->sym->name, f2_save); if (sym == NULL || !compare_type_rank (g->sym, sym) || ((gfc_option.allow_std & GFC_STD_F2008) - && ((sym->attr.allocatable && g->sym->attr.pointer) - || (sym->attr.pointer && g->sym->attr.allocatable)))) + && (compare_ptr_alloc(sym, g->sym) + || compare_ptr_alloc(g->sym, sym)))) return true; }