diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-17 15:41:28 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-18 09:08:07 +0100 |
commit | 63538444fbce73fff2948e3357939b520f59afb8 (patch) | |
tree | e8294499f3a0fdc409b80b40713f7281dac915e2 /gcc | |
parent | d120c9db1811752e543ef8c231c1501a63dfcea2 (diff) | |
download | gcc-63538444fbce73fff2948e3357939b520f59afb8.zip gcc-63538444fbce73fff2948e3357939b520f59afb8.tar.gz gcc-63538444fbce73fff2948e3357939b520f59afb8.tar.bz2 |
struct-base: Add location info on `..` token
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 8 | ||||
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index bacf1cd..7994aed 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -1514,11 +1514,11 @@ struct StructBase { private: std::unique_ptr<Expr> base_struct; + Location locus; public: - // TODO: should this store location data? - StructBase (std::unique_ptr<Expr> base_struct_ptr) - : base_struct (std::move (base_struct_ptr)) + StructBase (std::unique_ptr<Expr> base_struct_ptr, Location locus) + : base_struct (std::move (base_struct_ptr)), locus (locus) {} // Copy constructor requires clone @@ -1550,7 +1550,7 @@ public: StructBase &operator= (StructBase &&other) = default; // Returns a null expr-ed StructBase - error state - static StructBase error () { return StructBase (nullptr); } + static StructBase error () { return StructBase (nullptr, Location ()); } // Returns whether StructBase is in error state bool is_invalid () const { return base_struct == nullptr; } diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 8703ecb..445acad 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -14441,6 +14441,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_struct_partial ( AST::StructBase struct_base = AST::StructBase::error (); if (lexer.peek_token ()->get_id () == DOT_DOT) { + Location dot_dot_location = lexer.peek_token ()->get_locus (); lexer.skip_token (); // parse required struct base expr @@ -14458,7 +14459,8 @@ Parser<ManagedTokenSource>::parse_struct_expr_struct_partial ( // DEBUG: rust_debug ("struct/enum expr - parsed and validated base expr"); - struct_base = AST::StructBase (std::move (base_expr)); + struct_base + = AST::StructBase (std::move (base_expr), dot_dot_location); // DEBUG: rust_debug ("assigned struct base to new struct base "); |