diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-16 15:18:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-16 15:18:49 +0000 |
commit | 5514d9cec51d5ec7cc30dd6cdbfadfdddbe0aab3 (patch) | |
tree | 55051cad7f474f411d79ca1e86cc23d63138716d /gcc/rust/ast/rust-expr.h | |
parent | dcd758595f646a480947265ccc9833fdd3976b75 (diff) | |
parent | 6d1333ef46cba6ed9e1ace817f9cc649b7f7a1df (diff) | |
download | gcc-5514d9cec51d5ec7cc30dd6cdbfadfdddbe0aab3.zip gcc-5514d9cec51d5ec7cc30dd6cdbfadfdddbe0aab3.tar.gz gcc-5514d9cec51d5ec7cc30dd6cdbfadfdddbe0aab3.tar.bz2 |
Merge #801
801: operator overloading r=philberty a=philberty
This change adds operator overloading by following how the C++ front-end
does it. We are relying on GCC to inline the operator overloads which does
occur once optimizations are enabled. It also brings back the desurgared
compound assignment expression (e2b761b13e6ccd3a7af4100183bb13e32b5b0da0)
for lang_items such as add_assign. You can find more information on how the algorithm works in:
- c47d5cbdee9b701fb7753b44530fcb51f80b20fa
- a7fb60bb626f7b936bf117636db777a5f0df30c9
These were refactored in: 0f74fe23c6d602c257ba94b2522bd9d6a594609e
Fixes #249
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 05c78b7..3463f5a 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -102,13 +102,7 @@ protected: // Literal expression attribute body (non-macro attribute) class AttrInputLiteral : public AttrInput { - // Literal expression WITHOUT SUFFIX - // std::unique_ptr<LiteralExpr> literal_expr; - LiteralExpr - literal_expr; // as not using polymorphic behaviour, doesn't require pointer - // TODO: will require pointer if LiteralExpr is changed to have subclassing - - // TODO: should this store location data? + LiteralExpr literal_expr; public: AttrInputLiteral (LiteralExpr lit_expr) : literal_expr (std::move (lit_expr)) @@ -127,6 +121,13 @@ public: bool is_meta_item () const override { return false; } + LiteralExpr &get_literal () { return literal_expr; } + + AttrInputType get_attr_input_type () const final override + { + return AttrInput::AttrInputType::LITERAL; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ |