aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-10-19 15:23:26 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:13:12 +0100
commit2272cfb53e0721c4b7985d037d5e098621bee31a (patch)
treeb30a067640f9b3570fd1af12ed65f88af709ba5b /gcc/rust/ast/rust-ast.cc
parentdf4e37c7dcf41d87d33c8359741d262e2732528e (diff)
downloadgcc-2272cfb53e0721c4b7985d037d5e098621bee31a.zip
gcc-2272cfb53e0721c4b7985d037d5e098621bee31a.tar.gz
gcc-2272cfb53e0721c4b7985d037d5e098621bee31a.tar.bz2
gccrs: 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/ast/rust-ast.cc')
-rw-r--r--gcc/rust/ast/rust-ast.cc25
1 files changed, 7 insertions, 18 deletions
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index d9c493d..3e8d414 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -3036,7 +3036,7 @@ ExternalFunctionItem::as_string () const
// function params
str += "\n Function params: ";
- if (function_params.empty () && !has_variadics)
+ if (function_params.empty ())
{
str += "none";
}
@@ -3044,21 +3044,6 @@ ExternalFunctionItem::as_string () const
{
for (const auto &param : function_params)
str += "\n " + param.as_string ();
-
- if (has_variadics)
- {
- str += "\n variadic outer attrs: ";
- if (has_variadic_outer_attrs ())
- {
- for (const auto &attr : variadic_outer_attrs)
- str += "\n " + attr.as_string ();
- }
- else
- {
- str += "none";
- }
- str += "\n ... (variadic)";
- }
}
// add type on new line
@@ -3080,9 +3065,13 @@ NamedFunctionParam::as_string () const
{
std::string str = append_attributes (outer_attrs, OUTER);
- str += "\n" + name;
+ if (has_name ())
+ str += "\n" + name;
- str += "\n Type: " + param_type->as_string ();
+ if (is_variadic ())
+ str += "...";
+ else
+ str += "\n Type: " + param_type->as_string ();
return str;
}