aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2023-04-25 14:43:15 +0200
committerPhilip Herron <philip.herron@embecosm.com>2023-05-18 16:40:08 +0000
commit5c78ef9854b560940aeaf36e74439ce3f10d5eb2 (patch)
tree8a101ad7e9c074c19cd835e43517fad57e2690d0 /gcc
parentad7c998b21c719cfcfd40215fe737b4211b6eb66 (diff)
downloadgcc-5c78ef9854b560940aeaf36e74439ce3f10d5eb2.zip
gcc-5c78ef9854b560940aeaf36e74439ce3f10d5eb2.tar.gz
gcc-5c78ef9854b560940aeaf36e74439ce3f10d5eb2.tar.bz2
ast: Add `outer_attrs` to all `Item`s
gcc/rust/ChangeLog: * ast/rust-ast.h: Add `outer_attrs` to Item. * ast/rust-expr.h: Make use of new inheritance methods. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast.h5
-rw-r--r--gcc/rust/ast/rust-expr.h8
-rw-r--r--gcc/rust/ast/rust-item.h7
-rw-r--r--gcc/rust/ast/rust-macro.h12
4 files changed, 23 insertions, 9 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 56207bd..09a7351 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -933,6 +933,11 @@ public:
// behavior that we have items that can also be expressions?
bool is_item () const override { return true; }
+ virtual std::vector<Attribute> &get_outer_attrs () = 0;
+ virtual const std::vector<Attribute> &get_outer_attrs () const = 0;
+
+ virtual bool has_outer_attrs () const { return !get_outer_attrs ().empty (); }
+
protected:
// Clone function implementation as pure virtual method
virtual Item *clone_item_impl () const = 0;
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 2b23c24..3e7c93c 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -2762,15 +2762,15 @@ protected:
public:
Location get_locus () const override final { return locus; }
- // should never be called - error if called
- void set_outer_attrs (std::vector<Attribute> /* new_attrs */) override
+ std::vector<Attribute> &get_outer_attrs () override final
{
+ // RangeExpr cannot have any outer attributes
rust_assert (false);
}
- std::vector<Attribute> &get_outer_attrs () override
+ // should never be called - error if called
+ void set_outer_attrs (std::vector<Attribute> /* new_attrs */) override
{
- // RangeExpr cannot have any outer attributes
rust_assert (false);
}
};
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index fa38b7d..e60c3f0 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -979,8 +979,11 @@ public:
Visibility &get_visibility () { return visibility; }
const Visibility &get_visibility () const { return visibility; }
- std::vector<Attribute> &get_outer_attrs () { return outer_attrs; }
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
+ std::vector<Attribute> &get_outer_attrs () override { return outer_attrs; }
+ const std::vector<Attribute> &get_outer_attrs () const override
+ {
+ return outer_attrs;
+ }
};
// Rust module item - abstract base class
diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h
index 5f2544e..29bb9fa 100644
--- a/gcc/rust/ast/rust-macro.h
+++ b/gcc/rust/ast/rust-macro.h
@@ -541,8 +541,11 @@ public:
bool is_marked_for_strip () const override { return rule_name.empty (); }
// TODO: this mutable getter seems really dodgy. Think up better way.
- std::vector<Attribute> &get_outer_attrs () { return outer_attrs; }
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
+ std::vector<Attribute> &get_outer_attrs () override { return outer_attrs; }
+ const std::vector<Attribute> &get_outer_attrs () const override
+ {
+ return outer_attrs;
+ }
std::vector<MacroRule> &get_macro_rules () { return rules; }
const std::vector<MacroRule> &get_macro_rules () const { return rules; }
@@ -651,7 +654,10 @@ public:
return invoc_data.is_marked_for_strip ();
}
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
+ const std::vector<Attribute> &get_outer_attrs () const override
+ {
+ return outer_attrs;
+ }
std::vector<Attribute> &get_outer_attrs () override { return outer_attrs; }
void set_outer_attrs (std::vector<Attribute> new_attrs) override