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 000000000000..b5d65dc4bb65 --- /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, + } +}