From 949892cb959fa9c9d7f148aae746181cefd8b956 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Mon, 20 May 2024 17:57:52 +0200 Subject: [PATCH] gccrs: Add a new regression test over struct expr field We want to prevent regressions on struct expr field attribute parsing. gcc/testsuite/ChangeLog: * rust/compile/struct_expr_field_attributes.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- .../compile/struct_expr_field_attributes.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 gcc/testsuite/rust/compile/struct_expr_field_attributes.rs diff --git a/gcc/testsuite/rust/compile/struct_expr_field_attributes.rs b/gcc/testsuite/rust/compile/struct_expr_field_attributes.rs new file mode 100644 index 00000000000..b5d65dc4bb6 --- /dev/null +++ b/gcc/testsuite/rust/compile/struct_expr_field_attributes.rs @@ -0,0 +1,22 @@ +pub struct Test { + #[cfg(not(any( + target_os = "solaris", + target_os = "illumos", + target_os = "fuchsia", + target_os = "redox", + )))] + value: bool, + // { dg-warning "field is never read" "" { target *-*-* } .-1 } +} + +pub fn test() -> Test { + Test { + #[cfg(not(any( + target_os = "solaris", + target_os = "illumos", + target_os = "fuchsia", + target_os = "redox", + )))] + value: false, + } +} -- 2.47.2