From 04cc46cfe8cad9736ccf2d5c884af50e57b67ce6 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Thu, 21 Apr 2022 18:21:10 -0600 Subject: backend: handle deprecated attribute Signed-off-by: Zixing Liu --- gcc/rust/ast/rust-ast-full-test.cc | 9 ++++++++- gcc/rust/ast/rust-ast.h | 2 ++ gcc/rust/ast/rust-macro.h | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'gcc/rust/ast') 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 #include +#include #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 MetaItemInner::to_meta_name_value_str () const { - // TODO parse foo = bar + if (is_key_value_pair ()) + { + auto converted_item = static_cast (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 namespace Rust { namespace AST { @@ -816,6 +817,13 @@ public: Attribute to_attribute () const override; + inline std::pair get_name_value_pair () const + { + return std::pair (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 -- cgit v1.1