From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id D451D3858D37; Sun, 11 Feb 2024 20:11:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D451D3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D451D3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707682293; cv=none; b=R0eS7+zDuq7tLW8w/wHSThW9IDgO6DJkXF21d9/0FxCKBpqGYOJIv3tgCo4XpCbaI6kU/m/eO4Qe9B/T10D5b6Dpieqne/LjJCu/FYp3rvESRRnG/+QNyW8iqSuot9TftiBBNnNXT7lWfA/iNfyXRBLbHNrGf2zLPjVL/36x6KE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707682293; c=relaxed/simple; bh=/QDhTONYsFGVhL3A2qEcTCzfCC9UoNNwh/KCmLwYdgA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=DINoO3L/6cH883559hbPAN8fv1GgPOsp3oE30dV7abZFPJBlIRaGis6RXe//sTHDMo7GqRldvxYmelFKQwCfVUGIVppgPH1Y9FRtNWrD4JrE0PqWxKS+Y821vHGKuewtOEB0WDDXiZYTYKORyTqVsm3r/Jp0q5m6maagWyk4eVw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1707682289; x=1708287089; i=anlauf@gmx.de; bh=/QDhTONYsFGVhL3A2qEcTCzfCC9UoNNwh/KCmLwYdgA=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=APBb+RWw9E/iIORCS0P56EsAT81h623wHvfre95ygxo4SXAHYlIt/fw1AH8zXDHJ 8szlcBJYuda2+9mKut0vSNerIZWB50MbjBw0qKQw1eZFNfYNqy0dYxRH4UJcI/kAg ww66Nh1raJsL9gyUmRX3EUj93YsIjfJgZvzi0+ELgLxOEdYfyF197rNziXvkBxocO xg5vS5S5masOACwWh3I+qBpvtxs5K0V9yu+rFv7UuJXtVWkyeqKkPl04LBYAEf2g2 XVnfs8C1Bx+KJp6lFETo+HLfVd74laKjhL+JkodkbnaT0ug8YtH9P7dkhnDsj1Vem zB441SQ8lCUO+XHRrg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([93.207.90.238]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MQe5u-1rNnpG3Xao-00NeXg; Sun, 11 Feb 2024 21:11:28 +0100 Message-ID: <5a4694d0-c610-4297-8255-77a15cda92c4@gmx.de> Date: Sun, 11 Feb 2024 21:11:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fortran - Error compiling PDT Type-bound Procedures [PR82943/86148/86268] To: Alexander Westbrooks , gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: Content-Language: en-US From: Harald Anlauf In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:1LxHQ18fkC+r+D1DhAHgoo6abYQOn5zBAZMCLG9Z42BYqIaInOV j/GFBoTFsfEGfZqg/SQ1JmFyUL4D46dV6XshKoY5UpiBEsoml3a8wTToZClb7fb6RgGAYNs 0CKwBN78iEAfjxxJXqPixkxPVxV5kjwBNQEYZTQ1H7vDe4/qccLaxzRip7L3Z8/5KzFd5Gc JciEIzx0d/5Bbqb1la/tg== UI-OutboundReport: notjunk:1;M01:P0:L8F6wklxryY=;j5dKdUm4iTgV/xnIjwZNe/7sj27 h/jw+9ZBZEo1xiuf+9aPJiYqjup29nPIt9Bi+sO1saRH2zNdyJ7GS1j+WesC3obKCgc0tnLV/ QY6UElfolr6jDE2h5gtnCAJCRCcOHID7I98R430OU9qMCaysMKoTdc2nPrN/tc1YTSSL1SNa+ 87XGnnKGlketgTms6HmJwoPIZkwQhnKnSrzNsD1E9z4HOFvoRV7mdw3iicsbWxv0AWus3qtw9 bCeGLUeKLXtkZTmbik9lc53rsSQlDQM63QOdsyk/RP5XHiJyWZso+jnA7Vadt7avieirz0tdF acRKxyzSih0G4lzZISG9U/pKxLnx1QuTerJG9N7aUwLGIUmZzs+8SEyGBV2D09eVeSxcleTxm A2aRB+bXZ8uWAi0LUaNNtZHHR3lMrHdpxHlEsgONPNe8WDr/MT0REI7nwPByfUb4IWAcIEHSk xA9wZYq5o2RuH3eaicqaqZPBKvymdwCcVfcq/eKoaDmy5dSduzlSalSV11Ip6mfhgAsRbvLkD vUOqg+IvgV36I5ldjr7CgIz/L/nS6jqpI2vNp/9SLAce5q4VaOXnoWUbq5uCswJDBjW3RohQZ fSfJKxZiYZwasfp+cKI/v0rTmZak2smttfVRBrOTjf9Ehok0FHBhBCtbDsEWyWTp0KVq8uBqe x5p6+W4qQ342n9mWfMa8XkScEuf36jCgspJkzOGmGmWtnHLE4nCSNjKlEKDqlxspyHTPI1Ra1 hV/6kKCTLedQWecfaxLQ6JNvv0NAzdAePdNIVhn78i2MoVa95pvz8cpXsbx5Q6wsmjo+GdWOA uIqW2qUFdK1QIynCOABL5OASVvvhrdEmzyH9XUFv5Nc6A= X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Alex, I've been unable to apply your patch to my local trunk, likely due to whitespace issues my newsreader handles differently from your site. I see it inline instead of attached. A few general remarks: Please follow the general recommendation regarding style if possible, see https://www.gnu.org/prep/standards/standards.html#Formatting regarding formatting/whitespace use (5.1) and comments (5.2) Also, when an error message text spans multiple lines, please place the whitespace at the end of a line, not at the beginning of the new one: > + if ( resolve_bindings_derived->attr.pdt_template && > + !gfc_pdt_is_instance_of(resolve_bindings_derived, > + CLASS_DATA(me_arg)->ts.u.derived)) > + { > + gfc_error ("Argument %qs of %qs with PASS(%s) at %L must be of" > + " the parametric derived-type %qs", me_arg->name, proc->name, gfc_error ("Argument %qs of %qs with PASS(%s) at %L must be of " "the parametric derived-type %qs", me_arg->name, proc->name, > + me_arg->name, &where, resolve_bindings_derived->name); > + goto error; > + } The following change is almost unreadable: the lnegthy comment is split over three parts and almost hides the code. Couldn't this be combined into one comment before the function? > diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc > index fddf68f8398..11f4bac0415 100644 > --- a/gcc/fortran/symbol.cc > +++ b/gcc/fortran/symbol.cc > @@ -5172,6 +5172,35 @@ gfc_type_is_extension_of (gfc_symbol *t1, gfc_sym= bol > *t2) > return gfc_compare_derived_types (t1, t2); > } > > +/* Check if a parameterized derived type t2 is an instance of a PDT > template t1 */ > + > +bool > +gfc_pdt_is_instance_of(gfc_symbol *t1, gfc_symbol *t2) > +{ > + if ( !t1->attr.pdt_template || !t2->attr.pdt_type ) > + return false; > + > + /* > + in decl.cc, gfc_get_pdt_instance, a pdt instance is given a 3 > character prefix "Pdt", followed > + by an underscore list of the kind parameters, up to a maximum of 8. > + > + So to check if a PDT Type corresponds to the template, extract the > core derive_type name, > + and then see if it is type compatible by name... > + > + For example: > + > + Pdtf_2_2 -> extract out the 'f' -> see if the derived type 'f' is > compatible with symbol t1 > + */ > + > + // Starting at index 3 of the string in order to skip past the 'Pdt' > prefix > + // Also, here the length of the template name is used in order to avo= id > the > + // kind parameter suffixes that are placed at the end of PDT instance > names. > + if ( !(strncmp(&(t2->name[3]), t1->name, strlen(t1->name)) =3D=3D 0) = ) > + return false; > + > + return true; > +} > + > > /* Check if two typespecs are type compatible (F03:5.1.1.2): > If ts1 is nonpolymorphic, ts2 must be the same type. The following testcase tests for errors. I tried Intel and NAG on it after commenting the 'contains' section of the type desclaration. Both complained about subroutine deferred_len_param, e.g. Intel: A colon may only be used as a type parameter value in the declaration of an object that has the POINTER or ALLOCATABLE attribute. [THIS] class(param_deriv_type(:)), intent(inout) :: this NAG: Entity THIS of type PARAM_DERIV_TYPE(A=3D:) has a deferred length type parameter but is not a data pointer or allocatable Do we detect this after your patch? If the answer is yes, can we add another subroutine where we check for this error? (the dg-error suggests we only expect assumed len type parameters.) If no, maybe add a comment in the testcase that this subroutine may need updating later. > diff --git a/gcc/testsuite/gfortran.dg/pdt_37.f03 > b/gcc/testsuite/gfortran.dg/pdt_37.f03 > new file mode 100644 > index 00000000000..68d376fad25 > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/pdt_37.f03 > @@ -0,0 +1,34 @@ > +! { dg-do compile } > +! > +! Tests the fixes for PR82943. > +! > +! This test focuses on the errors produced by incorrect LEN parameters = for > dummy > +! arguments of PDT Typebound Procedures. > +! > +! Contributed by Alexander Westbrooks > +! > +module test_len_param > + > + type :: param_deriv_type(a) > + integer, len :: a > + contains > + procedure :: assumed_len_param ! Good. No error expect= ed. > + procedure :: deferred_len_param ! { dg-error "All LEN t= ype > parameters of the passed dummy argument" } > + procedure :: fixed_len_param ! { dg-error "All LEN t= ype > parameters of the passed dummy argument" } > + end type > + > +contains > + subroutine assumed_len_param(this) > + class(param_deriv_type(*)), intent(inout) :: this > + end subroutine > + > + subroutine deferred_len_param(this) > + class(param_deriv_type(:)), intent(inout) :: this > + end subroutine > + > + subroutine fixed_len_param(this) > + class(param_deriv_type(10)), intent(inout) :: this > + end subroutine > + > +end module > +