diff options
author | 0xn4utilus <gyanendrabanjare8@gmail.com> | 2024-02-26 04:39:43 +0530 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-03-05 15:08:36 +0000 |
commit | 87f797f0e827e50eb75945593d9107431f9be2ce (patch) | |
tree | 5ac287a4a12e3d8661b3ddd03244a2d391329fad /gcc/rust/resolve | |
parent | 0177e3cb1382d4eeefce0038b4791e7fb25bc2b9 (diff) | |
download | gcc-87f797f0e827e50eb75945593d9107431f9be2ce.zip gcc-87f797f0e827e50eb75945593d9107431f9be2ce.tar.gz gcc-87f797f0e827e50eb75945593d9107431f9be2ce.tar.bz2 |
Update resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.cc (FeatureGate::visit):
Check if function is_external or not.
* hir/rust-ast-lower-extern.h: Use AST::Function
instead of AST::ExternalFunctionItem.
* parse/rust-parse-impl.h (Parser::parse_external_item):
Likewise.
(Parser::parse_pattern): Fix clang format.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveExternItem::visit):
Likewise.
* resolve/rust-ast-resolve-item.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Check if param has_pattern before using get_pattern.
Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-implitem.h | 4 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-item.cc | 16 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-item.h | 2 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-default-resolver.cc | 3 |
4 files changed, 15 insertions, 10 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index 4f4d2893..fa344ef 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -189,11 +189,11 @@ public: item->accept_vis (resolver); }; - void visit (AST::ExternalFunctionItem &function) override + void visit (AST::Function &function) override { auto decl = CanonicalPath::new_seg (function.get_node_id (), - function.get_identifier ().as_string ()); + function.get_function_name ().as_string ()); auto path = prefix.append (decl); resolver->get_name_scope ().insert ( diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index 743657b..a3f27b3 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -1009,11 +1009,12 @@ ResolveExternItem::go (AST::ExternalItem *item, const CanonicalPath &prefix, } void -ResolveExternItem::visit (AST::ExternalFunctionItem &function) +ResolveExternItem::visit (AST::Function &function) { NodeId scope_node_id = function.get_node_id (); - auto decl = CanonicalPath::new_seg (function.get_node_id (), - function.get_identifier ().as_string ()); + auto decl + = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ().as_string ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -1038,9 +1039,12 @@ ResolveExternItem::visit (AST::ExternalFunctionItem &function) // we make a new scope so the names of parameters are resolved and shadowed // correctly - for (auto ¶m : function.get_function_params ()) - if (!param.is_variadic ()) - ResolveType::go (param.get_type ().get ()); + for (auto &it : function.get_function_params ()) + if (!it->is_variadic ()) + { + auto param = static_cast<AST::FunctionParam *> (it.get ()); + ResolveType::go (param->get_type ().get ()); + } // done resolver->get_name_scope ().pop (); diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h index e397ffd..0133d2c 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.h +++ b/gcc/rust/resolve/rust-ast-resolve-item.h @@ -111,7 +111,7 @@ public: static void go (AST::ExternalItem *item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix); - void visit (AST::ExternalFunctionItem &function) override; + void visit (AST::Function &function) override; void visit (AST::ExternalStaticItem &item) override; private: diff --git a/gcc/rust/resolve/rust-default-resolver.cc b/gcc/rust/resolve/rust-default-resolver.cc index 28f04a1..c99f2f6 100644 --- a/gcc/rust/resolve/rust-default-resolver.cc +++ b/gcc/rust/resolve/rust-default-resolver.cc @@ -62,7 +62,8 @@ DefaultResolver::visit (AST::Function &function) if (p->is_variadic ()) { auto param = static_cast<AST::VariadicParam *> (p.get ()); - param->get_pattern ()->accept_vis (*this); + if (param->has_pattern ()) + param->get_pattern ()->accept_vis (*this); } else if (p->is_self ()) { |