From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id AA4CF385840D; Tue, 2 May 2023 07:10:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA4CF385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683011448; bh=XrZvruX2yjNFOYd8wrZ1qHv6lZ5Ug11kDhP2ZNp//ok=; h=From:To:Subject:Date:From; b=nGfM4iZgrr4D1s5BzSk6uH9b8Adl9Ng4UaNsA0r7aj0cmffTj12+PzvTcSU+eu5Ve Nd2f5MzTbbNdsJd8v58OMkaktn/qbCDz0HD+QLN0jl8/q/FLFn2bCfVmwGMoX5qLn8 2vNnEWhaIgyLvvSQR0ZwAq/I7Q4y1950i6seQSbg= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] gccrs: fix ICE with recursive function calls X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 8f6680458524877c7803eb9821ccf5e83ecfd080 X-Git-Newrev: 727056301b2124649daacc29a23bb4b357a25173 Message-Id: <20230502071048.AA4CF385840D@sourceware.org> Date: Tue, 2 May 2023 07:10:48 +0000 (GMT) List-Id: https://gcc.gnu.org/g:727056301b2124649daacc29a23bb4b357a25173 commit 727056301b2124649daacc29a23bb4b357a25173 Author: Philip Herron Date: Thu Apr 20 12:33:55 2023 +0100 gccrs: fix ICE with recursive function calls Fixes #2136 gcc/rust/ChangeLog: * backend/rust-compile-item.cc (CompileItem::visit): remove bad checks gcc/testsuite/ChangeLog: * rust/compile/issue-2136-1.rs: New test. * rust/compile/issue-2136-2.rs: New test. Signed-off-by: Philip Herron Diff: --- gcc/rust/backend/rust-compile-item.cc | 14 ++------------ gcc/testsuite/rust/compile/issue-2136-1.rs | 14 ++++++++++++++ gcc/testsuite/rust/compile/issue-2136-2.rs | 13 +++++++++++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index e1e2bb6d5a0..c57acdf9872 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -147,18 +147,8 @@ CompileItem::visit (HIR::Function &function) if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup, fntype->get_id (), fntype, asm_name)) { - // has this been added to the list then it must be finished - if (ctx->function_completed (lookup)) - { - tree dummy = NULL_TREE; - if (!ctx->lookup_function_decl (fntype->get_ty_ref (), &dummy)) - { - ctx->insert_function_decl (fntype, lookup); - } - - reference = address_expression (lookup, ref_locus); - return; - } + reference = address_expression (lookup, ref_locus); + return; } if (fntype->has_subsititions_defined ()) diff --git a/gcc/testsuite/rust/compile/issue-2136-1.rs b/gcc/testsuite/rust/compile/issue-2136-1.rs new file mode 100644 index 00000000000..fcf1efcd171 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-2136-1.rs @@ -0,0 +1,14 @@ +pub trait Foo { + fn foo(); +} + +impl Foo for u16 { + fn foo() { + // { dg-warning "infinite recursion detected" "" { target *-*-* } .-1 } + ::foo() + } +} + +fn main() { + ::foo(); +} diff --git a/gcc/testsuite/rust/compile/issue-2136-2.rs b/gcc/testsuite/rust/compile/issue-2136-2.rs new file mode 100644 index 00000000000..7317f3f5151 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-2136-2.rs @@ -0,0 +1,13 @@ +struct S; + +impl S { + fn foo(self) { + // { dg-warning "infinite recursion detected" "" { target *-*-* } .-1 } + self.foo(); + } +} + +fn main() { + let a = S; + a.foo(); +}