diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-base.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index f138cb1..84afa1e 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -56,6 +56,8 @@ HIRCompileBase::setup_attributes_on_fndecl ( bool is_must_use = attr.get_path ().as_string ().compare ("must_use") == 0; bool is_cold = attr.get_path ().as_string ().compare ("cold") == 0; + bool is_link_section + = attr.get_path ().as_string ().compare ("link_section") == 0; if (is_inline) { handle_inline_attribute_on_fndecl (fndecl, attr); @@ -68,6 +70,10 @@ HIRCompileBase::setup_attributes_on_fndecl ( { handle_cold_attribute_on_fndecl (fndecl, attr); } + else if (is_link_section) + { + handle_link_section_attribute_on_fndecl (fndecl, attr); + } } } @@ -90,6 +96,31 @@ HIRCompileBase::handle_cold_attribute_on_fndecl (tree fndecl, } void +HIRCompileBase::handle_link_section_attribute_on_fndecl ( + tree fndecl, const AST::Attribute &attr) +{ + if (!attr.has_attr_input ()) + { + rust_error_at (attr.get_locus (), + "%<link_section%> expects exactly one argment"); + return; + } + + rust_assert (attr.get_attr_input ().get_attr_input_type () + == AST::AttrInput::AttrInputType::LITERAL); + + auto &literal = static_cast<AST::AttrInputLiteral &> (attr.get_attr_input ()); + const auto &msg_str = literal.get_literal ().as_string (); + + if (decl_section_name (fndecl)) + { + rust_warning_at (attr.get_locus (), 0, "section name redefined"); + } + + set_decl_section_name (fndecl, msg_str.c_str ()); +} + +void HIRCompileBase::handle_inline_attribute_on_fndecl (tree fndecl, const AST::Attribute &attr) { |