]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
ast: Add proper visitors for ExternalTypeItem
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 23 Feb 2023 15:59:20 +0000 (16:59 +0100)
committerCohenArthur <arthur.cohen@embecosm.com>
Fri, 24 Feb 2023 14:43:01 +0000 (14:43 +0000)
gcc/rust/ChangeLog:

* ast/rust-item.h: Add non-const `get_visibility` to ExternalTypeItem.
* ast/rust-ast-dump.cc (Dump::visit): Add implementation for ExternalTypeItem.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Likewise.

gcc/rust/ast/rust-ast-dump.cc
gcc/rust/ast/rust-item.h
gcc/rust/expand/rust-attribute-visitor.cc

index 1fd312a5b9435d85fc0ee3398f198a08d8ac6752..1cfcebbab9df0239e3b51f987142e695f8b5c163 100644 (file)
@@ -1434,7 +1434,11 @@ Dump::visit (TraitImpl &impl)
 
 void
 Dump::visit (ExternalTypeItem &type)
-{}
+{
+  visit (type.get_visibility ());
+
+  stream << "type " << type.get_identifier () << ';';
+}
 
 void
 Dump::visit (ExternalStaticItem &)
index 4be4ca1666f6dce775f9d99c244409d8da7c1c98..ab7d323607b802b1cd41e7c4071129c2c1509ec9 100644 (file)
@@ -3971,6 +3971,7 @@ public:
 
   Identifier get_identifier () const { return item_name; }
 
+  Visibility &get_visibility () { return visibility; }
   const Visibility &get_visibility () const { return visibility; }
 
 protected:
index a5aa8f0e6e96c613213e1178de051280bbec5a6a..ce93986003d7856f8cdb969abee3ca09bbbeeacc 100644 (file)
@@ -2738,7 +2738,14 @@ AttrVisitor::visit (AST::TraitImpl &impl)
 void
 AttrVisitor::visit (AST::ExternalTypeItem &item)
 {
-  // TODO: ARTHUR
+  expander.expand_cfg_attrs (item.get_outer_attrs ());
+
+  if (expander.fails_cfg_with_expand (item.get_outer_attrs ()))
+    item.mark_for_strip ();
+
+  // TODO: Can we do anything like expand a macro here?
+  // extern "C" { type ffi_ty!(); }
+  // ?
 }
 
 void