public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7664] gccrs: expand: Allow empty derive attribute
@ 2024-01-16 17:51 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 17:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:da450d345c948d9be1fca29d01fa1153c2ddf3bd
commit r14-7664-gda450d345c948d9be1fca29d01fa1153c2ddf3bd
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Mon Jun 5 13:17:22 2023 +0200
gccrs: expand: Allow empty derive attribute
Changes derive macro expansion to accept empty derive attributes. This
commit also add a test to prevent future regressions.
gcc/rust/ChangeLog:
* expand/rust-expand-visitor.cc (get_traits_to_derive): Change
assertion to allow empty derive directives.
gcc/testsuite/ChangeLog:
* rust/compile/derive_empty.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diff:
---
gcc/rust/expand/rust-expand-visitor.cc | 2 +-
gcc/testsuite/rust/compile/derive_empty.rs | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index 927d9225049..c7a5f573d7e 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -72,7 +72,7 @@ get_traits_to_derive (AST::Attribute &attr)
= static_cast<AST::DelimTokenTree &> (input).get_token_trees ();
// erase the delimiters
- rust_assert (tokens.size () >= 3);
+ rust_assert (tokens.size () >= 2);
tokens.erase (tokens.begin ());
tokens.pop_back ();
diff --git a/gcc/testsuite/rust/compile/derive_empty.rs b/gcc/testsuite/rust/compile/derive_empty.rs
new file mode 100644
index 00000000000..21c67f01d6c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/derive_empty.rs
@@ -0,0 +1,6 @@
+#[derive()]
+struct UnderivedStruct;
+
+fn main() {
+ let _ = UnderivedStruct;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 17:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 17:51 [gcc r14-7664] gccrs: expand: Allow empty derive attribute Arthur Cohen
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).