aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-10-19 15:23:26 +0200
committerPhilip Herron <philip.herron@embecosm.com>2023-11-09 15:39:45 +0000
commit44518d975cbad9ea7c8aa8a54f24fb91369d972b (patch)
tree36a61d8cfe5fd410e02f3053544c938c9534ac29 /gcc/rust/resolve
parentb47dee55b1b990f17788f74179a9a062fa4730d5 (diff)
downloadgcc-44518d975cbad9ea7c8aa8a54f24fb91369d972b.zip
gcc-44518d975cbad9ea7c8aa8a54f24fb91369d972b.tar.gz
gcc-44518d975cbad9ea7c8aa8a54f24fb91369d972b.tar.bz2
Fix multiple issues with variadic representation
The new variadic representation has introduced multiple issues and ICE into the codebase. Some early passes in the compiler depend on the parameters all having a type and being an actual parameter. gcc/rust/ChangeLog: * ast/rust-ast.cc (ExternalFunctionItem::as_string): Adapt as_string function to the new ast representation. (NamedFunctionParam::as_string): Likewise. * ast/rust-item.h: Add a function to test whether a FunctionParam has a name pattern. * expand/rust-cfg-strip.cc (CfgStrip::visit): Adapt cfg strip visitor for the new variadic arguments. * hir/rust-ast-lower-extern.h: Adapt lowering to the new variadic function representation. * metadata/rust-export-metadata.cc (ExportContext::emit_function): Change call to constructor. * parse/rust-parse-impl.h (Parser::parse_named_function_param): Change NamedFunctionParam parsing to accomodate new variadic representation. (Parser::parse_external_item): Change external item parsing to use the new NamedFunctionParam variadics. * parse/rust-parse.h: Add new parsing function prototypes. * ast/rust-ast-collector.cc (TokenCollector::visit): Rework token collection to take into account variadic parameters. * ast/rust-ast-visitor.cc: Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Change function bound to avoid getting the type of a variadic parameter. * resolve/rust-ast-resolve-item.cc (ResolveExternItem::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.cc3
-rw-r--r--gcc/rust/resolve/rust-early-name-resolver.cc3
2 files changed, 3 insertions, 3 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index 3b73092..96b739c 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -1115,9 +1115,8 @@ ResolveExternItem::visit (AST::ExternalFunctionItem &function)
// we make a new scope so the names of parameters are resolved and shadowed
// correctly
for (auto &param : function.get_function_params ())
- {
+ if (!param.is_variadic ())
ResolveType::go (param.get_type ().get ());
- }
// done
resolver->get_name_scope ().pop ();
diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc
index d19c384..85f8713 100644
--- a/gcc/rust/resolve/rust-early-name-resolver.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver.cc
@@ -872,7 +872,8 @@ EarlyNameResolver::visit (AST::ExternalFunctionItem &item)
generic->accept_vis (*this);
for (auto &param : item.get_function_params ())
- param.get_type ()->accept_vis (*this);
+ if (!param.is_variadic ())
+ param.get_type ()->accept_vis (*this);
if (item.has_return_type ())
item.get_return_type ()->accept_vis (*this);