diff mbox series

[105/125] gccrs: Recognize unstable as a builtin attribute

Message ID 20240801145809.366388-107-arthur.cohen@embecosm.com
State New
Headers show
Series [001/125] Rust: Make 'tree'-level 'MAIN_NAME_P' work | expand

Commit Message

Arthur Cohen Aug. 1, 2024, 2:57 p.m. UTC
From: Owen Avery <powerboat9.gamer@gmail.com>

gcc/rust/ChangeLog:

	* util/rust-attribute-values.h
	(Attributes::UNSTABLE): New.
	* util/rust-attributes.cc
	(__definitions): Add Attributes::UNSTABLE.

gcc/testsuite/ChangeLog:

	* rust/compile/unstable-fn.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
---
 gcc/rust/util/rust-attribute-values.h     | 1 +
 gcc/rust/util/rust-attributes.cc          | 3 ++-
 gcc/testsuite/rust/compile/unstable-fn.rs | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/rust/compile/unstable-fn.rs
diff mbox series

Patch

diff --git a/gcc/rust/util/rust-attribute-values.h b/gcc/rust/util/rust-attribute-values.h
index 04aef99be68..a8551c07dba 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -52,6 +52,7 @@  public:
   static constexpr auto &RUSTC_INHERIT_OVERFLOW_CHECKS
     = "rustc_inherit_overflow_checks";
   static constexpr auto &STABLE = "stable";
+  static constexpr auto &UNSTABLE = "unstable";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index e10918b2f8d..84d1781d0b3 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -60,7 +60,8 @@  static const BuiltinAttrDefinition __definitions[]
      // #![feature(rustc_attrs)]
      {Attrs::RUSTC_DEPRECATED, STATIC_ANALYSIS},
      {Attrs::RUSTC_INHERIT_OVERFLOW_CHECKS, CODE_GENERATION},
-     {Attrs::STABLE, STATIC_ANALYSIS}};
+     {Attrs::STABLE, STATIC_ANALYSIS},
+     {Attrs::UNSTABLE, STATIC_ANALYSIS}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --git a/gcc/testsuite/rust/compile/unstable-fn.rs b/gcc/testsuite/rust/compile/unstable-fn.rs
new file mode 100644
index 00000000000..4cbbebdb50e
--- /dev/null
+++ b/gcc/testsuite/rust/compile/unstable-fn.rs
@@ -0,0 +1,2 @@ 
+#[unstable(feature = "some_feature", issue = "12345")]
+pub fn foo() {}