diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2021-08-02 14:18:24 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2021-08-02 14:18:24 +0200 |
commit | a0628a62ad2a9024872b2ae1eb67a8c873cc80c6 (patch) | |
tree | bc2b019b911677a16618fdac1c7db2ec5fb69603 /gcc | |
parent | b56c6fdfaad9ca1681714d288d1282cf08554462 (diff) | |
download | gcc-a0628a62ad2a9024872b2ae1eb67a8c873cc80c6.zip gcc-a0628a62ad2a9024872b2ae1eb67a8c873cc80c6.tar.gz gcc-a0628a62ad2a9024872b2ae1eb67a8c873cc80c6.tar.bz2 |
Handle 'UnsafeBlockExpr' in liveness analysis
We may then remove the '{ dg-options "-w" }' as discussed in
<http://mid.mail-archive.com/YQciMeKNpCH+ZMsJ@wildebeest.org> and #601.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.h | 5 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/forward_decl_3-unsafe.rs | 13 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/union.rs | 3 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/unsafe4.rs | 12 |
4 files changed, 30 insertions, 3 deletions
diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h index 742175b..062bb96 100644 --- a/gcc/rust/lint/rust-lint-marklive.h +++ b/gcc/rust/lint/rust-lint-marklive.h @@ -107,6 +107,11 @@ public: } } + void visit (HIR::UnsafeBlockExpr &expr) override + { + expr.get_block_expr ()->accept_vis (*this); + } + void visit (HIR::LoopExpr &expr) override { expr.get_loop_block ()->accept_vis (*this); diff --git a/gcc/testsuite/rust/compile/torture/forward_decl_3-unsafe.rs b/gcc/testsuite/rust/compile/torture/forward_decl_3-unsafe.rs new file mode 100644 index 0000000..0493586 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/forward_decl_3-unsafe.rs @@ -0,0 +1,13 @@ +fn main() { + unsafe { + let struct_test = Foo { one: 1, two: 2 }; + // { dg-warning "unused name" "" { target *-*-* } .-1 } + }; +} + +struct Foo { + one: i32, + // { dg-warning "field is never read" "" { target *-*-* } .-1 } + two: i32, + // { dg-warning "field is never read" "" { target *-*-* } .-1 } +} diff --git a/gcc/testsuite/rust/compile/torture/union.rs b/gcc/testsuite/rust/compile/torture/union.rs index 393e591..7241688 100644 --- a/gcc/testsuite/rust/compile/torture/union.rs +++ b/gcc/testsuite/rust/compile/torture/union.rs @@ -1,6 +1,3 @@ -// { dg-do compile } -// { dg-options "-w" } - union U { f1: u8 diff --git a/gcc/testsuite/rust/compile/torture/unsafe4.rs b/gcc/testsuite/rust/compile/torture/unsafe4.rs new file mode 100644 index 0000000..6fe3101 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/unsafe4.rs @@ -0,0 +1,12 @@ +struct SS { + one: i32, + two: i32, +} +struct TS(i32, i32); + +fn main() { + unsafe { + let ss = SS { one: 1, two: 2 }; + let _ts = TS(ss.one, ss.two); + }; +} |