From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id BD2053858CD1; Thu, 29 Feb 2024 02:24:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD2053858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD2053858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709173470; cv=none; b=ur4a+1t/evhuiKdhPuPL7fW1AAeRo25P/QN/68TG8lSx9DRlIoJpVWvzquCZuHO0Zyzw+sV/fdAIjdA2vjQRVWjn+vdIx+hNmRR+osvjme5ct3WktnXxs8omjTV7tiffmcOzoeewAsiaPTExwTkTgkSs9PCLsRNNjmlY7MoJq34= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709173470; c=relaxed/simple; bh=JVnz8jkGWvZCv8QeANRcmnozDQ3DyHyDXHoMdh0xSok=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=stbuXP82vY+mc+SDJhmtjFwzoAFe1NJ0YADc61LjVOzIwxxyhRsxkOT70VQClzlw3uc+hKrBZLhyFz6iMQKQMvD6Ck2i/p6eTRa4fg0DfIhpzEtMnvryK70wpRXwoTqTYfPijJ7vOU3J8F1j1y32YBFH2jsfZWPOF7RWpWsgke8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a3e550ef31cso51794266b.3; Wed, 28 Feb 2024 18:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709173466; x=1709778266; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XkIhOV8JVdoTauR7git7rzseNcC8tbD+WBrg0Bz1ZeM=; b=YcuDdn5cbQZyLQtLDpfyV3eniT0t+Je7oHIYELqdj6xeViFLFthUsgbxE9EX57qHSg 9GxHzjuJKqvxsW2omNNc02wkINt4dWXqKjwYwvB/RNkXVk0iqnI26d778Q6DxZarTH1E pThqkzHTLZKwHYAFsc0VnonOF84Okqsmp1wAEhYpxmwubQASxrj7+7R/zyrjissd1lBD byfiYBKGQeHMfXhZ+ny1L90OihPzRPfOL3F/v5fldtdrkY8xZImHOLLiAHtDj6+0PwGg FgPLJ3T/9rj6PqAYvr0vWtZKr9POHEX8as61PIA4ikht7tdMcnXlPT2SN7QQ57dyVdNA zafg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709173466; x=1709778266; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XkIhOV8JVdoTauR7git7rzseNcC8tbD+WBrg0Bz1ZeM=; b=a/oW2kuxu7h1aQM0+MkXd3EaOcG4ad9GGzT8rLniABuHh6vxQoA8OrE4+J5DdJvYW0 5WVjaCawz2gB3CO+FXEAFwq3+6QayVM8m/vpPGDtE1fgIUSKx3aaTrJcT3QlwQ79rj15 Bqm79+DE7yIsD6wqxvxe39ue5wih6hdNtXSAk8xntU0yIHH47+qfpN3aGOZFjYf5/5BF 68zMtGiEwftTtUIxLS3yEQl7x3X5keV1rgZzneMWs3QMumiwosFeDb2hTMJ4pEkT3PuN 17JpZU66HJoOrf0a6udNbZzy5htODRNRK30ZbmlmIICT8I2jSHHsS+wF6g3lUKj2lDLK yc9w== X-Forwarded-Encrypted: i=1; AJvYcCUorX5nlGn63yzc60tm3576uxRe9iulHxaGT2wAtGQVRVE15UFckXFKNWHGOWfkLDeQXePvEouDaHop0Uzb852XIrGZ X-Gm-Message-State: AOJu0YwG8BZgWAkCebBul0p4oDQnRsie1yCduTLqqYsquC/zfkExnPua Wsk0A9uxtjyhQYb0Gjp9zW/iLTUXPUXFJyOGb9mhlUdE1GfgGbCrql+69an02WO9doTOu0wSaoU Y3WRlCHs7k+Pn0fIBMISibtuucok= X-Google-Smtp-Source: AGHT+IGEKjQUVEAelSilzqiGa9YNSWfls8C71ONEkjRYnluBvOEvZvnEBav7je3Ykin/X3l0vUI2mv2OanRsznkX//U= X-Received: by 2002:a17:906:3bd2:b0:a41:3e39:b918 with SMTP id v18-20020a1709063bd200b00a413e39b918mr445205ejf.24.1709173465735; Wed, 28 Feb 2024 18:24:25 -0800 (PST) MIME-Version: 1.0 References: <5a4694d0-c610-4297-8255-77a15cda92c4@gmx.de> In-Reply-To: From: Alexander Westbrooks Date: Wed, 28 Feb 2024 20:24:14 -0600 Message-ID: Subject: Re: [PATCH] Fortran - Error compiling PDT Type-bound Procedures [PR82943/86148/86268] To: Harald Anlauf Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.8 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_NONE,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: Hello, I've updated the patch with those changes, ran through the gcc-verify step and fixed up the commit, and then pushed it to the trunk. Thank you for your feedback, and I look forward to working on GFortran. Thanks, Alexander Westbrooks On Wed, Feb 28, 2024 at 1:55=E2=80=AFPM Harald Anlauf wrote= : > > Hi Alex, > > this is now mostly correct, with the following exceptions: > > First, you should notice that the formatting of the commit message, > when checked using "git gcc-verify", needs minor corrections. You > will be guided how to fix this yourself. > > Second, testcase pdt_37.f03 has an undeclared dummy argument, which > can be detected by adding "implicit none" (I usually use that > whenever implicit typing is not wanted explicitly). I would get: > > pdt_37.f03:33:47: > > 33 | subroutine assumed_len_param_ptr(this, that) > | 1 > Error: Symbol 'that' at (1) has no IMPLICIT type; did you mean 'this'? > > I assume you want to uncomment the declaration of dummy 'that'. > > Third, I still see a - minor - indentation/tabbing/space issue here: > > diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc > index 44f89f6afb4..852e0820e6a 100644 > --- a/gcc/fortran/resolve.cc > +++ b/gcc/fortran/resolve.cc > [...] > + if ( resolve_bindings_derived->attr.pdt_template > + && gfc_pdt_is_instance_of (resolve_bindings_derived, > + CLASS_DATA (me_arg)->ts.u.derived) > + && (me_arg->param_list !=3D NULL) > + && (gfc_spec_list_type (me_arg->param_list, > + CLASS_DATA(me_arg)->ts.u.derived) > + !=3D SPEC_ASSUMED)) > > OK with the above fixed. > > Thanks for the patch! > > Harald > > On 2/28/24 07:24, Alexander Westbrooks wrote: > > Harald, > > > > Jerry helped me figure out my editor settings so that I could fix > > whitespace and formatting issues in my code. With my editor configured > > correctly, I saw that my code was not conforming to coding standards > > as I previously thought it was. I have fixed those things and updated > > my patch. Thank you for your patience. > > > > Let me know if this is okay to push to the trunk. > > > > Thanks, > > > > Alexander Westbrooks > > > > On Sun, Feb 25, 2024 at 2:40=E2=80=AFPM Alexander Westbrooks > > wrote: > >> > >> Harald, > >> > >> Thank you for reviewing my code. I've been doing research and debuggin= g to investigate the error thrown by Intel and NAG for the deferred paramet= er in the dummy variable declaration. I found where the problem was and add= ed the fix as part of my patch. I've attached the patch as a file, which al= so includes your feedback and suggested fixes. I've updated the test case p= dt_37.f03 to check for the POINTER or ALLOCATABLE error as you suggested. > >> > >> All regression tests pass, including the new ones, after including the= fix for the POINTER or ALLOCATABLE error for CLASS declarations of PDTs wh= en deferred length parameters are used. This was tested on WSL 2, with Ubun= tu 20.04 distro. > >> > >> Is this okay to push to the trunk? > >> > >> Thanks, > >> > >> Alexander Westbrooks > >> > >> > >> On Sun, Feb 11, 2024 at 2:11=E2=80=AFPM Harald Anlauf = wrote: > >>> > >>> 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 t= he > >>> 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 o= f" > >>>> + " the parametric derived-type %qs", me_arg->name, proc->nam= e, > >>> > >>> gfc_error ("Argument %qs of %qs with PASS(%s) at %L must be o= f " > >>> "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 spl= it > >>> over three parts and almost hides the code. Couldn't this be combine= d > >>> 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= _symbol > >>>> *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 o= f 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 'P= dt' > >>>> prefix > >>>> + // Also, here the length of the template name is used in order to= avoid > >>>> the > >>>> + // kind parameter suffixes that are placed at the end of PDT inst= ance > >>>> 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 typ= e > >>> 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 paramet= ers 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 ex= pected. > >>>> + procedure :: deferred_len_param ! { dg-error "All L= EN type > >>>> parameters of the passed dummy argument" } > >>>> + procedure :: fixed_len_param ! { dg-error "All L= EN type > >>>> 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 > >>>> + > >>> >