From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id D199F3858421; Mon, 10 Jul 2023 18:55:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D199F3858421 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1689015330; x=1689620130; i=anlauf@gmx.de; bh=VLDJCN2RcN9dzeP7vqXh3ImYQ1ZycVBd7I0RPa7fUOw=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=lavbAPQTGr6MUiuCLTMrh3oQ5hmhq1PM8izKKBVFZz077HLcwyJ9BnwYPvUZbbMZLVzZnhI 0/8/6O4AD5aTCk6/mB4K8l1F8XPQ6nQVfMpAMpQCm3RkaqnWoQKgWDOCydjZlA9VNh/h+5dnE zIcXBjr+5HczERGX2+d+6KFx4pIpG1Rpe/NJJ6MzwZ3K8D0Dhvww68twg/SV/4yXcWji9Hz7R OEhkffjEjXunhwfFFLZ7UR3iFZnQUICtexrlEoMSwxxrXrnfy7UawH/QpuRzKdp8qGsafSFrL eBv2Lk4U+prs9qeic7UCBOK2ai6AGOMT9qGrvsjP7eh1EuY3V1ig== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([79.232.144.96]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N8GMq-1px1VK35GK-0149ac; Mon, 10 Jul 2023 20:55:30 +0200 Message-ID: <3114593a-0197-62cd-41e9-59f2a8ae9f29@gmx.de> Date: Mon, 10 Jul 2023 20:55:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [Patch, Fortran] Allow ref'ing PDT's len() in parameter-initializer [PR102003] To: Andre Vehreschild , GCC-Patches-ML , GCC-Fortran-ML , Paul Richard Thomas Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: <20230710174826.48f9230c@vepi2> Content-Language: en-US From: Harald Anlauf In-Reply-To: <20230710174826.48f9230c@vepi2> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:L+DCkZzbZ7nI1WUR7npqDFhe02Y0awvJH74d+YVoai62VC/CcZa yerZBUo2Jx4zeEMSLLDdGihub80CJJj78xDW9N0s8+JknWfWBpbO5k+Ja8auHEuhVp1mJrp OpYENiWIveOqaBMAscIcOWY7ep3Skq+j7NrX2NEj5R2D96/xOTIxuBvk1vVXDxOe9utfuVL EKZZs5e44VKdWqPWj39ug== UI-OutboundReport: notjunk:1;M01:P0:YOaapaRkhyk=;5Hq761+QKtok5ArqPVoOj48+Q7h sB3RJaKu+kmx5iHx6yKq/X+8G8l0pe3u7khUSxxqdJlecrne/c78uTZ64IbKxYqfzLzN2IYnD SRwFaRv677yYWM3L14jwLxOOWCEX0uZmfnl4MOJWsvNxtEJ062hpZ4KA5yPriOaiBjibLPuBS 8oGfDGE4KvLfNQQuA1HWudVu8q7oZEyhr2Qt/QaeVsc0y0gGM8HB8mL3XOGpnd8P52h0d+iKD epZZsUazOEpynK/4WUgQn9ZujT3RoTGXEU2QFCALY+GT0c/Y8amhiSCU84PHBD5Mf7tFPcqPu 2EZszYxVeZOktGfoCgPrk4wdpMdLSD6x415bv2MRDRAu20jT4qjoydPlXOPJ1H7BMNUWnTAdD vM4r115cqBLDOpQ2l5TD4oHsd7NuwOEj0pmYR7xZumQg0t+a1cHMcrq9mhdrEOzPYrFEbhxCp ooZxjoLlp+CbZOZpNqphzN26tuJvkQ8PKXx+TJkCt7aLZy39MWSPHlvo8AzDEe7IbdGbBcA9t D7Usgf42iOUgQiXauJl74eU5kX991LpPVKu4ADu6x/yoq5XJxKDvVHTDvkXhj/52Y3BclYhZK Pqf/apMaEUbHg6PL5nKxa/byBYCly2Dqs4nQUI+xLqdQy1QY23SM+vo/T9qVFiDc0jN+h4vaJ WFotjvMWsI3AOOVnBF9sQJHgGbuU18k1caBCzWhbsJHDptJZGAUehOPHcWLttv0tYw7Orfiju fJRgr/OfBBbhZaV3Cer/Dj1mIx4Y9WMkzYu0d4/VMhCtGEU2AaPxSUeJxWP9V5iGk7O62JOYs VM/jvTcZC/qbAG2Lg6Z+tBVRGbcP5pI6d3urOYvKtKJyPvx/e2F5Wcb3FPTpfkWd5eU5UXr6m n9csD28Z+Su2A1j+kmBck6s9r8KRtG43MUgdzZ2Buh2aXH2Bb72x9nSDpKBLsx7QVpO2ZxOLY 0YnyxPfih+1noQKwy42J+DL2TIc= X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_PORT 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 Andre, thanks for looking into this! While it fixes the original PR, here is a minor extension of the testcase that ICEs here with your patch: program pr102003 type pdt(n) integer, len :: n =3D 8 character(len=3Dn) :: c end type pdt type(pdt(42)) :: p integer, parameter :: m =3D len (p% c) integer, parameter :: n =3D p% c% len if (m /=3D 42) stop 1 if (len (p% c) /=3D 42) stop 2 print *, p% c% len ! OK if (p% c% len /=3D 42) stop 3 ! OK print *, n ! ICE end I get: pdt_33.f03:14:27: 14 | integer, parameter :: n =3D p% c% len | 1 Error: non-constant initialization expression at (1) pdt_33.f03:20:31: 20 | print *, n ! ICE | 1 internal compiler error: tree check: expected record_type or union_type or qual_union_type, have integer_type in gfc_conv_component_ref, at fortran/trans-expr.cc:2757 0x84286c tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc-trunk/gcc/tree.cc:8899 0xa6d6fb tree_check3(tree_node*, char const*, int, char const*, tree_code, tree_code, tree_code) ../../gcc-trunk/gcc/tree.h:3617 0xa90847 gfc_conv_component_ref(gfc_se*, gfc_ref*) ../../gcc-trunk/gcc/fortran/trans-expr.cc:2757 0xa91bbc gfc_conv_variable ../../gcc-trunk/gcc/fortran/trans-expr.cc:3137 0xaa8e9c gfc_conv_expr(gfc_se*, gfc_expr*) ../../gcc-trunk/gcc/fortran/trans-expr.cc:9594 0xaa92ae gfc_conv_expr_reference(gfc_se*, gfc_expr*) ../../gcc-trunk/gcc/fortran/trans-expr.cc:9713 0xad67f6 gfc_trans_transfer(gfc_code*) ../../gcc-trunk/gcc/fortran/trans-io.cc:2607 0xa43cb7 trans_code ../../gcc-trunk/gcc/fortran/trans.cc:2449 0xad37c6 build_dt ../../gcc-trunk/gcc/fortran/trans-io.cc:2051 0xa43cd7 trans_code ../../gcc-trunk/gcc/fortran/trans.cc:2421 0xa84711 gfc_generate_function_code(gfc_namespace*) ../../gcc-trunk/gcc/fortran/trans-decl.cc:7762 0x9d9ca7 translate_all_program_units ../../gcc-trunk/gcc/fortran/parse.cc:6929 0x9d9ca7 gfc_parse_file() ../../gcc-trunk/gcc/fortran/parse.cc:7235 0xa40a1f gfc_be_parse_file ../../gcc-trunk/gcc/fortran/f95-lang.cc:229 The fortran-dump confirms that n is not simplified to a constant. So while you're at it, do you also see a solution to this variant? Harald Am 10.07.23 um 17:48 schrieb Andre Vehreschild via Gcc-patches: > Hi all, > > while browsing the pdt meta-bug I came across 102003 and thought to myse= lf: > Well, that one is easy. How foolish of me... > > Anyway, the solution attached prevents a pdt_len (or pdt_kind) expressio= n in a > function call (e.g. len() or kind()) to mark the whole expression as a p= dt one. > The second part of the patch in simplify.cc then takes care of either ge= nerating > the correct component ref or when a constant expression (i.e. > gfc_init_expr_flag is set) is required to look this up from the actual s= ymbol > (not from the type, because there the default value is stored). > > Regtested ok on x86_64-linux-gnu/Fedora 37. > > Regards, > Andre > -- > Andre Vehreschild * Email: vehre ad gmx dot de