aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2020-05-18 11:08:48 +0100
committerPhilip Herron <philip.herron@embecosm.com>2020-11-28 21:13:13 +0000
commit0833b2d55e3fea376b47f4f260cf87b050d6a5e7 (patch)
treefae4b439e9792e7e9f5344e26aabaaab351ed6e0
parent40a5081072f2069447b3d3267f8b00a16433ab91 (diff)
downloadgcc-0833b2d55e3fea376b47f4f260cf87b050d6a5e7.zip
gcc-0833b2d55e3fea376b47f4f260cf87b050d6a5e7.tar.gz
gcc-0833b2d55e3fea376b47f4f260cf87b050d6a5e7.tar.bz2
For tuple structs the constructor is just a regular function call
This is a hack to get the AST to become a CallExpr more changes might occur later to cleanup this side of the AST.
-rw-r--r--gcc/rust/parse/rust-parse.cc14
-rw-r--r--gcc/rust/parse/rust-parse.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/gcc/rust/parse/rust-parse.cc b/gcc/rust/parse/rust-parse.cc
index 5e9443f..4624403 100644
--- a/gcc/rust/parse/rust-parse.cc
+++ b/gcc/rust/parse/rust-parse.cc
@@ -10892,7 +10892,7 @@ Parser::parse_path_based_stmt_or_expr (
case LEFT_PAREN: {
// assume struct expr tuple (as struct-enum disambiguation requires name
// lookup) again, make statement if final ';'
- ::std::unique_ptr<AST::StructExprTuple> struct_expr
+ ::std::unique_ptr<AST::CallExpr> struct_expr
= parse_struct_expr_tuple_partial (::std::move (path),
::std::move (outer_attrs));
if (struct_expr == NULL)
@@ -13229,7 +13229,7 @@ Parser::parse_struct_expr_struct_partial (
// Parses a struct expr tuple with a path in expression already parsed (but not
// '(' token).
-::std::unique_ptr<AST::StructExprTuple>
+::std::unique_ptr<AST::CallExpr>
Parser::parse_struct_expr_tuple_partial (
AST::PathInExpression path, ::std::vector<AST::Attribute> outer_attrs)
{
@@ -13272,10 +13272,12 @@ Parser::parse_struct_expr_tuple_partial (
Location path_locus = path.get_locus ();
- return ::std::unique_ptr<AST::StructExprTuple> (
- new AST::StructExprTuple (::std::move (path), ::std::move (exprs),
- ::std::move (inner_attrs),
- ::std::move (outer_attrs), path_locus));
+ auto pathExpr = ::std::unique_ptr<AST::PathInExpression> (
+ new AST::PathInExpression (::std::move (path)));
+
+ return ::std::unique_ptr<AST::CallExpr> (
+ new AST::CallExpr (::std::move (pathExpr), ::std::move (exprs),
+ ::std::move (outer_attrs), path_locus));
}
/* Parses a path in expression with the first token passed as a parameter (as it
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index 5abfba6..5bbfefc 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -407,7 +407,7 @@ private:
::std::unique_ptr<AST::StructExprStruct>
parse_struct_expr_struct_partial (AST::PathInExpression path,
::std::vector<AST::Attribute> outer_attrs);
- ::std::unique_ptr<AST::StructExprTuple>
+ ::std::unique_ptr<AST::CallExpr>
parse_struct_expr_tuple_partial (AST::PathInExpression path,
::std::vector<AST::Attribute> outer_attrs);
AST::PathInExpression parse_path_in_expression_pratt (const_TokenPtr tok);