From patchwork Wed Sep 22 14:58:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 45286 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D97B53857C6F for ; Wed, 22 Sep 2021 14:58:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id BF3DF3858D39; Wed, 22 Sep 2021 14:58:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BF3DF3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: OdkfQ0KziqZHrcAeu2GXIIjpAWI/T4Kn6LuGLjhXSI+gSwifXc+16ARo7DGwXUHT9rX19BOIJT f6pOr8USFVKup6bqRV6/2zj1fj8yQxCsJZVfnbDG7vrmdQRCSCTtWE2b8jmmCHU8LfQcbrDMrY +EuozLbbtIh8wUkZBz1tplJVvS0BAM/iAWm6gKLHGZuyRPPPW5bP+c3fQACQKVjgFqM5AgaWVB Y6tb5o8Ikwi5pxi7Km6fId+TvMgvo+3RS/rHFxcd1TEr67QegWw9bqTBwOcSjQqEbL9VIcrGvp vHK4OGibOpsz/K+WX+9WFCeZ X-IronPort-AV: E=Sophos;i="5.85,314,1624348800"; d="scan'208";a="66165153" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 22 Sep 2021 06:58:14 -0800 IronPort-SDR: C41Jkb85dxdgZvJIIusz8bn2nCCuA0V3v3igfXgbeawX/F+/X1vo2OqSpFf+hw6+sD+1AxhbuE s6jKENr5Jo55m2WedyOkNlS5c+ZyuYdtcagJqLCvkvg+YpvglpylutcJSH/wKLp14s7WE/qw61 bqU+AkrRRbDwjYAJ6NsPLt19coAcK1kTE/h6HAddhMmPgwBbyrEjKy1uLbv/mC/KnbgaxrJhgV Qa1cTAsb/AoJC2PxKXFLqWGAB4YaEf3zYzZtknWgnZQHw+Dnwuxgti0iRYd4eH6J9K1H1sDe2h 1E4= To: "fortran@gcc.gnu.org" , "gcc-patches@gcc.gnu.org" From: Sandra Loosemore Subject: [PATCH, Fortran] diagnostic for argument w/type parameters for assumed-type dummy Message-ID: <8bc80383-d339-eff3-36e5-3250c73745e9@codesourcery.com> Date: Wed, 22 Sep 2021 08:58:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 Content-Language: en-US X-ClientProxiedBy: svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch is adds the missing diagnostic noted in PR fortran/101319. OK to commit? -Sandra commit 9d5b9062d728d1b1bf5acfb914e06d776bdcdb60 Author: Sandra Loosemore Date: Wed Sep 22 07:49:17 2021 -0700 Fortran: diagnostic for argument w/type parameters for assumed-type dummy 2021-09-22 Sandra Loosemore PR fortran/101319 gcc/fortran/ * interface.c (gfc_compare_actual_formal): Extend existing assumed-type diagnostic to also check for argument with type parameters. gcc/testsuite/ * gfortran.dg/c-interop/assumed-type-dummy.f90: Remove xfail. diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index f9a7c9c..dae4b95 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -3183,21 +3183,21 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, is_elemental, where)) return false; - /* TS 29113, 6.3p2. */ + /* TS 29113, 6.3p2; F2018 15.5.2.4. */ if (f->sym->ts.type == BT_ASSUMED && (a->expr->ts.type == BT_DERIVED || (a->expr->ts.type == BT_CLASS && CLASS_DATA (a->expr)))) { - gfc_namespace *f2k_derived; - - f2k_derived = a->expr->ts.type == BT_DERIVED - ? a->expr->ts.u.derived->f2k_derived - : CLASS_DATA (a->expr)->ts.u.derived->f2k_derived; - - if (f2k_derived - && (f2k_derived->finalizers || f2k_derived->tb_sym_root)) + gfc_symbol *derived = (a->expr->ts.type == BT_DERIVED + ? a->expr->ts.u.derived + : CLASS_DATA (a->expr)->ts.u.derived); + gfc_namespace *f2k_derived = derived->f2k_derived; + if (derived->attr.pdt_type + || (f2k_derived + && (f2k_derived->finalizers || f2k_derived->tb_sym_root))) { - gfc_error ("Actual argument at %L to assumed-type dummy is of " + gfc_error ("Actual argument at %L to assumed-type dummy " + "has type parameters or is of " "derived type with type-bound or FINAL procedures", &a->expr->where); return false; diff --git a/gcc/testsuite/gfortran.dg/c-interop/assumed-type-dummy.f90 b/gcc/testsuite/gfortran.dg/c-interop/assumed-type-dummy.f90 index a14c9a5..24bdf2b 100644 --- a/gcc/testsuite/gfortran.dg/c-interop/assumed-type-dummy.f90 +++ b/gcc/testsuite/gfortran.dg/c-interop/assumed-type-dummy.f90 @@ -73,7 +73,7 @@ contains type(t4) :: a4 call s1 (a1) ! OK - call s1 (a2) ! { dg-error "assumed-type dummy" "pr101319" { xfail *-*-* } } + call s1 (a2) ! { dg-error "assumed-type dummy" } call s1 (a3) ! { dg-error "assumed-type dummy" } call s1 (a4) ! { dg-error "assumed-type dummy" } end subroutine