diff options
author | Antonio Gomes <antoniospg100@gmail.com> | 2024-07-18 22:50:54 -0300 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:00 +0100 |
commit | af654898a7b10b8789f6f0246169e24f4743643c (patch) | |
tree | 4d211671adabfd21ea427121ffd2f44be0981077 /gcc/testsuite/rust | |
parent | 9a13dc48a3ac3282aaf9a77516b4f02faa60e393 (diff) | |
download | gcc-af654898a7b10b8789f6f0246169e24f4743643c.zip gcc-af654898a7b10b8789f6f0246169e24f4743643c.tar.gz gcc-af654898a7b10b8789f6f0246169e24f4743643c.tar.bz2 |
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 <antoniospg100@gmail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r-- | gcc/testsuite/rust/compile/macro-issue2983_2984.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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" } + }; +} |