aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-06-20 14:28:17 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2022-06-20 14:28:59 +0200
commit48492dc805868572d2d2bcd1ad0d00b0a08b3569 (patch)
tree1b6f2a6545cbd27a352e6c2057966a43d32f9e03
parentc0f11672d760513256997f325da678016d13f677 (diff)
downloadgcc-48492dc805868572d2d2bcd1ad0d00b0a08b3569.zip
gcc-48492dc805868572d2d2bcd1ad0d00b0a08b3569.tar.gz
gcc-48492dc805868572d2d2bcd1ad0d00b0a08b3569.tar.bz2
ast: Add location to ConstGenericArg
-rw-r--r--gcc/rust/ast/rust-path.h21
-rw-r--r--gcc/rust/parse/rust-parse-impl.h4
2 files changed, 15 insertions, 10 deletions
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 5642226..232f11c 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -156,19 +156,20 @@ public:
static ConstGenericArg create_error ()
{
- return ConstGenericArg (nullptr, "", Kind::Error);
+ return ConstGenericArg (nullptr, "", Kind::Error, Location ());
}
- ConstGenericArg (std::unique_ptr<Expr> expression)
- : expression (std::move (expression)), path (""), kind (Kind::Clear)
+ ConstGenericArg (std::unique_ptr<Expr> expression, Location locus)
+ : expression (std::move (expression)), path (""), kind (Kind::Clear),
+ locus (locus)
{}
- ConstGenericArg (Identifier path)
- : expression (nullptr), path (path), kind (Kind::Ambiguous)
+ ConstGenericArg (Identifier path, Location locus)
+ : expression (nullptr), path (path), kind (Kind::Ambiguous), locus (locus)
{}
ConstGenericArg (const ConstGenericArg &other)
- : path (other.path), kind (other.kind)
+ : path (other.path), kind (other.kind), locus (other.locus)
{
if (other.expression)
expression = other.expression->clone_expr ();
@@ -178,6 +179,7 @@ public:
{
kind = other.kind;
path = other.path;
+ locus = other.locus;
if (other.expression)
expression = other.expression->clone_expr ();
@@ -206,8 +208,9 @@ public:
private:
ConstGenericArg (std::unique_ptr<AST::Expr> expression, Identifier path,
- Kind kind)
- : expression (std::move (expression)), path (std::move (path)), kind (kind)
+ Kind kind, Location locus)
+ : expression (std::move (expression)), path (std::move (path)), kind (kind),
+ locus (locus)
{}
/**
@@ -226,6 +229,8 @@ private:
/* Which kind of const generic application are we dealing with */
Kind kind;
+
+ Location locus;
};
// Generic arguments allowed in each path expression segment - inline?
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index c2efd53..708140a 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -6181,7 +6181,7 @@ Parser<ManagedTokenSource>::parse_const_generic_expression ()
// special variant here
// FIXME: We need locus here as well
- return AST::ConstGenericArg (tok->get_str ());
+ return AST::ConstGenericArg (tok->get_str (), tok->get_locus ());
case LEFT_CURLY:
expr = parse_block_expr ();
break;
@@ -6201,7 +6201,7 @@ Parser<ManagedTokenSource>::parse_const_generic_expression ()
if (!expr)
return AST::ConstGenericArg::create_error ();
- return AST::ConstGenericArg (std::move (expr));
+ return AST::ConstGenericArg (std::move (expr), tok->get_locus ());
}
// Parses the generic arguments in each path segment.