diff options
author | 0xn4utilus <gyanendrabanjare8@gmail.com> | 2024-02-28 19:35:30 +0530 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-03-05 15:08:36 +0000 |
commit | 53d8e04c0b4a4834658397dc61352cf8928c6b51 (patch) | |
tree | a5255a43bf793610de7b3f9d26301187b5ecd3cb /gcc/rust/expand | |
parent | 87f797f0e827e50eb75945593d9107431f9be2ce (diff) | |
download | gcc-53d8e04c0b4a4834658397dc61352cf8928c6b51.zip gcc-53d8e04c0b4a4834658397dc61352cf8928c6b51.tar.gz gcc-53d8e04c0b4a4834658397dc61352cf8928c6b51.tar.bz2 |
Remove dead code associated with `AST::ExternalFunctionItem`
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit):
Remove dead code.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-full-decls.h (class ExternalFunctionItem):
Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):
Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-ast.cc (ExternalFunctionItem::as_string): Likewise.
(ExternalFunctionItem::accept_vis): Likewise.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Likewise.
* checks/errors/rust-ast-validation.h: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::visit):
Likewise.
* expand/rust-cfg-strip.h: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit):
Likewise.
* expand/rust-expand-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit):
Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* metadata/rust-export-metadata.cc (ExportContext::emit_function):
Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit):
Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Likewise.
* resolve/rust-default-resolver.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h: Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/extern_func_with_body.rs: New test.
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r-- | gcc/rust/expand/rust-cfg-strip.cc | 56 | ||||
-rw-r--r-- | gcc/rust/expand/rust-cfg-strip.h | 1 | ||||
-rw-r--r-- | gcc/rust/expand/rust-derive.h | 1 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.cc | 17 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.h | 1 |
5 files changed, 0 insertions, 76 deletions
diff --git a/gcc/rust/expand/rust-cfg-strip.cc b/gcc/rust/expand/rust-cfg-strip.cc index 2b51a89..923015f 100644 --- a/gcc/rust/expand/rust-cfg-strip.cc +++ b/gcc/rust/expand/rust-cfg-strip.cc @@ -2196,62 +2196,6 @@ CfgStrip::visit (AST::ExternalStaticItem &item) } void -CfgStrip::visit (AST::ExternalFunctionItem &item) -{ - // strip test based on outer attrs - expand_cfg_attrs (item.get_outer_attrs ()); - if (fails_cfg_with_expand (item.get_outer_attrs ())) - { - item.mark_for_strip (); - return; - } - - AST::DefaultASTVisitor::visit (item); - - /* strip function parameters if required - this is specifically - * allowed by spec */ - auto ¶ms = item.get_function_params (); - for (auto it = params.begin (); it != params.end ();) - { - auto ¶m = *it; - - auto ¶m_attrs = param.get_outer_attrs (); - expand_cfg_attrs (param_attrs); - if (fails_cfg_with_expand (param_attrs)) - { - it = params.erase (it); - continue; - } - - if (!param.is_variadic ()) - { - auto &type = param.get_type (); - if (type->is_marked_for_strip ()) - rust_error_at (type->get_locus (), - "cannot strip type in this position"); - } - - // increment if nothing else happens - ++it; - } - /* NOTE: these are extern function params, which may have different - * rules and restrictions to "normal" function params. So expansion - * handled separately. */ - - /* TODO: assuming that variadic nature cannot be stripped. If this - * is not true, then have code here to do so. */ - - if (item.has_return_type ()) - { - auto &return_type = item.get_return_type (); - - if (return_type->is_marked_for_strip ()) - rust_error_at (return_type->get_locus (), - "cannot strip type in this position"); - } -} - -void CfgStrip::visit (AST::ExternBlock &block) { // initial strip test based on outer attrs diff --git a/gcc/rust/expand/rust-cfg-strip.h b/gcc/rust/expand/rust-cfg-strip.h index a393182..4a8e604 100644 --- a/gcc/rust/expand/rust-cfg-strip.h +++ b/gcc/rust/expand/rust-cfg-strip.h @@ -150,7 +150,6 @@ public: void visit (AST::TraitImpl &impl) override; void visit (AST::ExternalTypeItem &item) override; void visit (AST::ExternalStaticItem &item) override; - void visit (AST::ExternalFunctionItem &item) override; void visit (AST::ExternBlock &block) override; // I don't think it would be possible to strip macros without expansion diff --git a/gcc/rust/expand/rust-derive.h b/gcc/rust/expand/rust-derive.h index f953c3d..cbe5bbb 100644 --- a/gcc/rust/expand/rust-derive.h +++ b/gcc/rust/expand/rust-derive.h @@ -166,7 +166,6 @@ private: virtual void visit (TraitImpl &impl) override final{}; virtual void visit (ExternalTypeItem &type) override final{}; virtual void visit (ExternalStaticItem &item) override final{}; - virtual void visit (ExternalFunctionItem &item) override final{}; virtual void visit (ExternBlock &block) override final{}; virtual void visit (MacroMatchFragment &match) override final{}; virtual void visit (MacroMatchRepetition &match) override final{}; diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index bd49fd9..6c1efb1 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -923,23 +923,6 @@ ExpandVisitor::visit (AST::ExternalStaticItem &static_item) } void -ExpandVisitor::visit (AST::ExternalFunctionItem &item) -{ - for (auto ¶m : item.get_generic_params ()) - visit (param); - - for (auto ¶m : item.get_function_params ()) - if (!param.is_variadic ()) - maybe_expand_type (param.get_type ()); - - if (item.has_return_type ()) - maybe_expand_type (item.get_return_type ()); - - if (item.has_where_clause ()) - expand_where_clause (item.get_where_clause ()); -} - -void ExpandVisitor::visit (AST::ExternBlock &block) { visit_inner_attrs (block); diff --git a/gcc/rust/expand/rust-expand-visitor.h b/gcc/rust/expand/rust-expand-visitor.h index f40b577..034aeed 100644 --- a/gcc/rust/expand/rust-expand-visitor.h +++ b/gcc/rust/expand/rust-expand-visitor.h @@ -252,7 +252,6 @@ public: void visit (AST::TraitImpl &impl) override; void visit (AST::ExternalTypeItem &item) override; void visit (AST::ExternalStaticItem &item) override; - void visit (AST::ExternalFunctionItem &item) override; void visit (AST::ExternBlock &block) override; // I don't think it would be possible to strip macros without expansion |