public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] ast: Add proper visitors for ExternalTypeItem
Date: Tue, 28 Feb 2023 22:36:24 +0000 (GMT)	[thread overview]
Message-ID: <20230228223624.03D973858412@sourceware.org> (raw)

https://gcc.gnu.org/g:9a0f9fb8ba2140fb365b9c771c733401de929ff2

commit 9a0f9fb8ba2140fb365b9c771c733401de929ff2
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Thu Feb 23 16:59:20 2023 +0100

    ast: Add proper visitors for ExternalTypeItem
    
    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.

Diff:
---
 gcc/rust/ast/rust-ast-dump.cc             | 6 +++++-
 gcc/rust/ast/rust-item.h                  | 1 +
 gcc/rust/expand/rust-attribute-visitor.cc | 9 ++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 1fd312a5b94..1cfcebbab9d 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -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 &)
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 4be4ca1666f..ab7d323607b 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -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:
diff --git a/gcc/rust/expand/rust-attribute-visitor.cc b/gcc/rust/expand/rust-attribute-visitor.cc
index a5aa8f0e6e9..ce93986003d 100644
--- a/gcc/rust/expand/rust-attribute-visitor.cc
+++ b/gcc/rust/expand/rust-attribute-visitor.cc
@@ -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

                 reply	other threads:[~2023-02-28 22:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230228223624.03D973858412@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).