aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-06-24 07:21:34 +0000
committerGitHub <noreply@github.com>2022-06-24 07:21:34 +0000
commite6b7d184d01f032efe5c41d5503945081c7a0aea (patch)
tree1b6f2a6545cbd27a352e6c2057966a43d32f9e03
parentc0f11672d760513256997f325da678016d13f677 (diff)
parent48492dc805868572d2d2bcd1ad0d00b0a08b3569 (diff)
downloadgcc-e6b7d184d01f032efe5c41d5503945081c7a0aea.zip
gcc-e6b7d184d01f032efe5c41d5503945081c7a0aea.tar.gz
gcc-e6b7d184d01f032efe5c41d5503945081c7a0aea.tar.bz2
Merge #1326
1326: ast: Add location to ConstGenericArg r=CohenArthur a=CohenArthur Closes #1320 Sorry for taking a good-first-pr but this is starting to be needed :) Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
-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.