From af654898a7b10b8789f6f0246169e24f4743643c Mon Sep 17 00:00:00 2001 From: Antonio Gomes Date: Thu, 18 Jul 2024 22:50:54 -0300 Subject: gccrs: Properly striping struct fields when using attrs gcc/rust/ChangeLog: * expand/rust-cfg-strip.cc: Strip struct expr fields and strip fields in struct definition * expand/rust-cfg-strip.h: Signatures for new function maybe_strip_struct_expr_fields gcc/testsuite/ChangeLog: * rust/compile/macro-issue2983_2984.rs: Add test to check for correct stripped fields Signed-off-by: Antonio Gomes --- gcc/testsuite/rust/compile/macro-issue2983_2984.rs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gcc/testsuite/rust/compile/macro-issue2983_2984.rs (limited to 'gcc/testsuite/rust') diff --git a/gcc/testsuite/rust/compile/macro-issue2983_2984.rs b/gcc/testsuite/rust/compile/macro-issue2983_2984.rs new file mode 100644 index 0000000..637d572 --- /dev/null +++ b/gcc/testsuite/rust/compile/macro-issue2983_2984.rs @@ -0,0 +1,27 @@ +pub struct ReadDir { + pub inner: i32, + #[cfg(not(A))] + pub end_of_stream: bool, + #[cfg(A)] + pub end_of_stream_but_different: bool, +} + +fn main() { + // Success + let _ = ReadDir { + inner: 14, + #[cfg(not(A))] + end_of_stream: false, + #[cfg(A)] + end_of_stream_but_different: false, + }; + + // Error + let _ = ReadDir { + inner: 14, + end_of_stream: false, + end_of_stream_but_different: false, // { dg-error "failed to resolve type for field" } + // { dg-error "unknown field" "" { target *-*-* } .-1 } + // { dg-prune-output "compilation terminated" } + }; +} -- cgit v1.1