diff options
author | liushuyu <liushuyu011@gmail.com> | 2022-04-21 18:21:10 -0600 |
---|---|---|
committer | liushuyu <liushuyu011@gmail.com> | 2022-06-28 17:22:56 -0600 |
commit | 04cc46cfe8cad9736ccf2d5c884af50e57b67ce6 (patch) | |
tree | 5af977f854130cdbb443e4819841d3aa634fed1d /gcc/rust/ast | |
parent | 65a06a817585faf7fb44fbc1c71173a00f9a407f (diff) | |
download | gcc-04cc46cfe8cad9736ccf2d5c884af50e57b67ce6.zip gcc-04cc46cfe8cad9736ccf2d5c884af50e57b67ce6.tar.gz gcc-04cc46cfe8cad9736ccf2d5c884af50e57b67ce6.tar.bz2 |
backend: handle deprecated attribute
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast-full-test.cc | 9 | ||||
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 2 | ||||
-rw-r--r-- | gcc/rust/ast/rust-macro.h | 8 |
3 files changed, 18 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index 0d4d36b..8179113 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -20,10 +20,12 @@ along with GCC; see the file COPYING3. If not see // FIXME: This does not work on Windows #include <string> #include <unistd.h> +#include <memory> #include "rust-ast-full.h" #include "rust-diagnostics.h" #include "rust-ast-visitor.h" +#include "rust-macro.h" #include "rust-session-manager.h" #include "rust-lex.h" #include "rust-parse.h" @@ -3862,7 +3864,12 @@ MetaItemInner::~MetaItemInner () = default; std::unique_ptr<MetaNameValueStr> MetaItemInner::to_meta_name_value_str () const { - // TODO parse foo = bar + if (is_key_value_pair ()) + { + auto converted_item = static_cast<const MetaNameValueStr *> (this); + return converted_item->to_meta_name_value_str (); + } + // TODO actually parse foo = bar return nullptr; } diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 76324dc..51fe3c4 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -645,6 +645,8 @@ public: virtual Attribute to_attribute () const { return Attribute::create_empty (); } virtual bool check_cfg_predicate (const Session &session) const = 0; + + virtual bool is_key_value_pair () const { return false; } }; // Container used to store MetaItems as AttrInput (bridge-ish kinda thing) diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 1bf8912..ce515db 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -21,6 +21,7 @@ #include "rust-ast.h" #include "rust-location.h" +#include <string> namespace Rust { namespace AST { @@ -816,6 +817,13 @@ public: Attribute to_attribute () const override; + inline std::pair<Identifier, std::string> get_name_value_pair () const + { + return std::pair<Identifier, std::string> (ident, str); + } + + bool is_key_value_pair () const override { return true; } + protected: // Use covariance to implement clone function as returning this type MetaNameValueStr *clone_meta_item_inner_impl () const override |