diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-10-18 15:30:57 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 19:13:12 +0100 |
commit | df4e37c7dcf41d87d33c8359741d262e2732528e (patch) | |
tree | d10c2e4989b121392b0c7f41ede32a31b6edc7d8 /gcc/rust/ast | |
parent | 41f480d16d3c6cc1e901d2ae3fcd4a9b5706aa51 (diff) | |
download | gcc-df4e37c7dcf41d87d33c8359741d262e2732528e.zip gcc-df4e37c7dcf41d87d33c8359741d262e2732528e.tar.gz gcc-df4e37c7dcf41d87d33c8359741d262e2732528e.tar.bz2 |
gccrs: Allow variadic NamedFunctionParam
This was made to align NamedFunctionParam with FunctionParam.
gcc/rust/ChangeLog:
* ast/rust-item.h (class NamedFunctionParam): Add variadic boolean and
another constructor.
* hir/rust-ast-lower-extern.h: Avoid last parameter when variadic.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-item.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 109680a..7cdbc8b 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -4166,6 +4166,7 @@ class NamedFunctionParam NodeId node_id; location_t locus; + bool variadic; public: /* Returns whether the named function parameter has a name (i.e. name is not @@ -4178,7 +4179,7 @@ public: bool is_error () const { // also if identifier is "" but that is probably more costly to compute - return param_type == nullptr; + return param_type == nullptr && !variadic; } std::string get_name () const { return name; } @@ -4195,17 +4196,35 @@ public: std::vector<Attribute> outer_attrs, location_t locus) : name (std::move (name)), param_type (std::move (param_type)), outer_attrs (std::move (outer_attrs)), - node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus) + node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus), + variadic (false) + {} + + NamedFunctionParam (std::string name, std::vector<Attribute> outer_attrs, + location_t locus) + : name (std::move (name)), param_type (nullptr), + outer_attrs (std::move (outer_attrs)), + node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus), + variadic (true) + {} + + NamedFunctionParam (std::vector<Attribute> outer_attrs, location_t locus) + : name (""), param_type (nullptr), outer_attrs (std::move (outer_attrs)), + node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus), + variadic (true) {} // Copy constructor NamedFunctionParam (NamedFunctionParam const &other) - : name (other.name), outer_attrs (other.outer_attrs) + : name (other.name), outer_attrs (other.outer_attrs), + variadic (other.variadic) { node_id = other.node_id; // guard to prevent null dereference (only required if error state) if (other.param_type != nullptr) param_type = other.param_type->clone_type (); + else + param_type = nullptr; } ~NamedFunctionParam () = default; |