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] Add feature gate definition for `extern_types`. Date: Sun, 5 Mar 2023 11:41:09 +0000 (GMT) [thread overview] Message-ID: <20230305114109.21E353858C52@sourceware.org> (raw) https://gcc.gnu.org/g:9c46a853be4b5a9c2e1b965fa0dcd44beed71924 commit 9c46a853be4b5a9c2e1b965fa0dcd44beed71924 Author: mxlol233 <mxlol233@outlook.com> Date: Wed Mar 1 19:31:19 2023 +0800 Add feature gate definition for `extern_types`. This commit add a basic implementation to gating `ExternalTypeItem` AST node. gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc: Add definition for `extern_types`. * checks/errors/rust-feature-gate.h: Likewise. * checks/errors/rust-feature.cc: Likewise. * checks/errors/rust-feature.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/feature_extern_types.rs:New file. Signed-off-by: Xiao Ma <mxlol233@outlook.com> Diff: --- gcc/rust/checks/errors/rust-feature-gate.cc | 13 +++++++++++++ gcc/rust/checks/errors/rust-feature-gate.h | 2 +- gcc/rust/checks/errors/rust-feature.cc | 5 +++++ gcc/rust/checks/errors/rust-feature.h | 1 + gcc/testsuite/rust/compile/feature_extern_types.rs | 8 ++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc index 9b2f025689f..07d367e6292 100644 --- a/gcc/rust/checks/errors/rust-feature-gate.cc +++ b/gcc/rust/checks/errors/rust-feature-gate.cc @@ -103,6 +103,10 @@ FeatureGate::visit (AST::ExternBlock &block) gate (Feature::Name::INTRINSICS, block.get_locus (), "intrinsics are subject to change"); } + for (const auto &item : block.get_extern_items ()) + { + item->accept_vis (*this); + } } void @@ -155,4 +159,13 @@ FeatureGate::visit (AST::Function &function) check_rustc_attri (function.get_outer_attrs ()); } +void +FeatureGate::visit (AST::ExternalTypeItem &item) +{ + // TODO(mxlol233): The gating needs a complete visiting chain to activate + // `AST::ExternalTypeItem`. + gate (Feature::Name::EXTERN_TYPES, item.get_locus (), + "extern types are experimental"); +} + } // namespace Rust \ No newline at end of file diff --git a/gcc/rust/checks/errors/rust-feature-gate.h b/gcc/rust/checks/errors/rust-feature-gate.h index 0262903f123..c442fd3d7d0 100644 --- a/gcc/rust/checks/errors/rust-feature-gate.h +++ b/gcc/rust/checks/errors/rust-feature-gate.h @@ -133,7 +133,7 @@ public: void visit (AST::Trait &trait) override {} void visit (AST::InherentImpl &impl) override; void visit (AST::TraitImpl &impl) override; - void visit (AST::ExternalTypeItem &item) override {} + void visit (AST::ExternalTypeItem &item) override; void visit (AST::ExternalStaticItem &item) override {} void visit (AST::ExternalFunctionItem &item) override {} void visit (AST::ExternBlock &block) override; diff --git a/gcc/rust/checks/errors/rust-feature.cc b/gcc/rust/checks/errors/rust-feature.cc index ceae2aaddec..e36e540035f 100644 --- a/gcc/rust/checks/errors/rust-feature.cc +++ b/gcc/rust/checks/errors/rust-feature.cc @@ -43,6 +43,10 @@ Feature::create (Feature::Name name) return Feature (Feature::Name::DECL_MACRO, Feature::State::ACCEPTED, "decl_macro", "1.0.0", 0, Optional<CompileOptions::Edition>::none (), ""); + case Feature::Name::EXTERN_TYPES: + return Feature (Feature::Name::EXTERN_TYPES, Feature::State::ACTIVE, + "extern_types", "1.23.0", 43467, + Optional<CompileOptions::Edition>::none (), ""); default: gcc_unreachable (); } @@ -56,6 +60,7 @@ const std::map<std::string, Feature::Name> Feature::name_hash_map = { // TODO: Rename to "auto_traits" when supporting // later Rust versions {"optin_builtin_traits", Feature::Name::AUTO_TRAITS}, + {"extern_types", Feature::Name::EXTERN_TYPES}, }; // namespace Rust Optional<Feature::Name> diff --git a/gcc/rust/checks/errors/rust-feature.h b/gcc/rust/checks/errors/rust-feature.h index 1f580a00a0a..7562eaf594b 100644 --- a/gcc/rust/checks/errors/rust-feature.h +++ b/gcc/rust/checks/errors/rust-feature.h @@ -42,6 +42,7 @@ public: RUSTC_ATTRS, DECL_MACRO, AUTO_TRAITS, + EXTERN_TYPES, }; const std::string &as_string () { return m_name_str; } diff --git a/gcc/testsuite/rust/compile/feature_extern_types.rs b/gcc/testsuite/rust/compile/feature_extern_types.rs new file mode 100644 index 00000000000..5e314931d6a --- /dev/null +++ b/gcc/testsuite/rust/compile/feature_extern_types.rs @@ -0,0 +1,8 @@ +extern "C" { + type F; //{ dg-error "extern types are experimental." "" { target *-*-* } } +} + + +fn main() { + +}
reply other threads:[~2023-03-05 11:41 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=20230305114109.21E353858C52@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: linkBe 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).