aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-base.h
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-04-02 16:16:47 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-04-08 10:17:12 +0200
commitb1afef95601fd2f0323dd508a171267ff04f755b (patch)
treeca7ffda51fd9e0424c9a8c3d8d74d941124ebd69 /gcc/rust/backend/rust-compile-base.h
parent4f110b297d4e764df001099b1fb647dddf8ac278 (diff)
downloadgcc-b1afef95601fd2f0323dd508a171267ff04f755b.zip
gcc-b1afef95601fd2f0323dd508a171267ff04f755b.tar.gz
gcc-b1afef95601fd2f0323dd508a171267ff04f755b.tar.bz2
gccrs: Fix ICE when there are 2 functions named main
We need to setup the main_identifier_node for MAIN_DECL_P checks in the middle-end. But it is valid to have a main function/method on impl blocks. So we need to flag if this is a "root" item or not, which is one that is jsut an HIR::Function on part of the Crate::items as oppposed to a HIR::Function which is part of an HIR::ImplBlock as part of the HIR::Crate. Some small cleanups have been added here too. Fixes Rust-GCC#3648 gcc/rust/ChangeLog: * backend/rust-compile-base.cc: new flag is_root_item * backend/rust-compile-base.h: update prototype * backend/rust-compile-implitem.cc (CompileTraitItem::visit): update call * backend/rust-compile-implitem.h: remove old debug internal error * backend/rust-compile-item.cc (CompileItem::visit): update call * backend/rust-compile-item.h: remove old debug * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): update calls * backend/rust-compile.cc: likewise * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): remove assertion and error gcc/testsuite/ChangeLog: * rust/compile/issue-3648.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-base.h')
-rw-r--r--gcc/rust/backend/rust-compile-base.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h
index 4b4f8b0..64c8106 100644
--- a/gcc/rust/backend/rust-compile-base.h
+++ b/gcc/rust/backend/rust-compile-base.h
@@ -102,7 +102,8 @@ protected:
HIR::Expr &const_value_expr, location_t locus,
location_t expr_locus);
- tree compile_function (const std::string &fn_name, HIR::SelfParam &self_param,
+ tree compile_function (bool is_root_item, const std::string &fn_name,
+ HIR::SelfParam &self_param,
std::vector<HIR::FunctionParam> &function_params,
const HIR::FunctionQualifiers &qualifiers,
HIR::Visibility &visibility, AST::AttrVec &outer_attrs,