From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) by sourceware.org (Postfix) with ESMTPS id BD3D93849AD9 for ; Fri, 19 Apr 2024 09:09:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD3D93849AD9 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gdcproject.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gdcproject.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD3D93849AD9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2050:0:465::102 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713517764; cv=none; b=qK9IJWIT//VGvfofVSurl3sJWq5C4LUDMhHIM+X1HocygxZnTwQLlZ8M/YDga/yeFtGPDbYhSRzLG6acfZqLuhNvcxMNO57/1ZzRgtfQaY2mHZJ5M4n67bx8eNvdOMyR3/rNmp19EZqQMDZw5or1CaEAQD+auj0GC0cEvJETkCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713517764; c=relaxed/simple; bh=6pMEoMPXQX0JJaf+u2XVGZP9ha1gKTRBrb0U0e4aMq8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=d0SXsu7H19NFaKjPHm2oQfEuUWWZWNmIpHNXyTtTv2XyBy7z6VJNVDmsddjuiZ4Y6ICoOdQAddDqRls4/D/WYSjDHrN6bM6TYGSd8bmWI7UTkMPLMV8WM+WaGb1SMpSyhbrLcT1NyHen12hi7CMyQ6QY8IflsuXTbHvnTTWKhX0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4VLTNZ0L0lz9scH; Fri, 19 Apr 2024 11:09:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gdcproject.org; s=MBO0001; t=1713517758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=FBDFf8+FYPG+HPL33/9i3JNpk5gEyQzKJ8ebZcV4L/w=; b=ERv184o89PYmnjY7wcfDMoLRuG2RUO1Vyn8+cwUacJVwYBY2jJaCyPhDWkLLDC4WQyWViG L+m0lgGcvjH+gvBfppp0fNOxf500nnUdOcmkT8vubWHFWgsQbNmiS8rv2ZgdNyOrd5KIkb tr4VTkTrzaeLs0ffLLz7VtKp+ES5w/vwNl1nOYe/yTG3OegM8it5+d9ZwCrpEs47ilDXPR Z7C50t5R2OiDgVsXukJ2DA2HncMVM8zMAnxDth5GkLEkP3OOAMLJ2+aTc0lsFajPoKDRn9 Q7a3y5qLuBI//HHkLhpEmQkWp6Q155zIhPFM4taGBrh8YhDVH0Tfsu3yBzkpPg== From: Iain Buclaw To: gcc-patches@gcc.gnu.org Cc: Iain Buclaw Subject: [committed] d: Fix ICE in build_deref, at d/d-codegen.cc:1650 [PR111650] Date: Fri, 19 Apr 2024 11:09:14 +0200 Message-Id: <20240419090914.28612-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP,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, This regression in the D front-end was found to be caused by in some cases the hidden closure parameter type being generated too early for nested functions. Better to update the type after the local closure/frame type has been completed. Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-m64, committed to mainline, and backporting to releases/gcc-13. Regards, Iain. --- PR d/111650 gcc/d/ChangeLog: * decl.cc (get_fndecl_arguments): Move generation of frame type to ... (DeclVisitor::visit (FuncDeclaration *)): ... here, after the call to build_closure. gcc/testsuite/ChangeLog: * gdc.dg/pr111650.d: New test. --- gcc/d/decl.cc | 20 ++++++++++---------- gcc/testsuite/gdc.dg/pr111650.d | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/pr111650.d diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 3b7627d3dfa..0a87c85ae2e 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -163,16 +163,6 @@ get_fndecl_arguments (FuncDeclaration *decl) tree parm_decl = get_symbol_decl (decl->vthis); DECL_ARTIFICIAL (parm_decl) = 1; TREE_READONLY (parm_decl) = 1; - - if (decl->vthis->type == Type::tvoidptr) - { - /* Replace generic pointer with back-end closure type - (this wins for gdb). */ - tree frame_type = FRAMEINFO_TYPE (get_frameinfo (decl)); - gcc_assert (frame_type != NULL_TREE); - TREE_TYPE (parm_decl) = build_pointer_type (frame_type); - } - param_list = chainon (param_list, parm_decl); } @@ -1072,6 +1062,16 @@ public: /* May change cfun->static_chain. */ build_closure (d); + /* Replace generic pointer with back-end closure type + (this wins for gdb). */ + if (d->vthis && d->vthis->type == Type::tvoidptr) + { + tree frame_type = FRAMEINFO_TYPE (get_frameinfo (d)); + gcc_assert (frame_type != NULL_TREE); + tree parm_decl = get_symbol_decl (d->vthis); + TREE_TYPE (parm_decl) = build_pointer_type (frame_type); + } + if (d->vresult) declare_local_var (d->vresult); diff --git a/gcc/testsuite/gdc.dg/pr111650.d b/gcc/testsuite/gdc.dg/pr111650.d new file mode 100644 index 00000000000..4298a76d38f --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr111650.d @@ -0,0 +1,21 @@ +// { dg-do compile } +ref V require(K, V)(ref V[K] aa, K key, lazy V value); + +struct Root +{ + ulong[3] f; +} + +Root[ulong] roots; + +Root getRoot(int fd, ulong rootID) +{ + return roots.require(rootID, + { + Root result; + inoLookup(fd, () => result); + return result; + }()); +} + +void inoLookup(int, scope Root delegate()) { } -- 2.40.1