aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Young <wenzhang5800@gmail.com>2021-06-27 00:48:07 +0800
committerThomas Young <wenzhang5800@gmail.com>2021-06-27 01:08:22 +0800
commita89ee61180a95a9d67f074d5f165e33d8e345bc9 (patch)
tree8c61c14be8fc50e3aecca0754bec186889843205
parent6952f9871f74f60090fa311c709bf66c4bb3a3d9 (diff)
downloadgcc-a89ee61180a95a9d67f074d5f165e33d8e345bc9.zip
gcc-a89ee61180a95a9d67f074d5f165e33d8e345bc9.tar.gz
gcc-a89ee61180a95a9d67f074d5f165e33d8e345bc9.tar.bz2
mark live symbol in return expr
-rw-r--r--gcc/rust/lint/rust-lint-marklive.h6
-rw-r--r--gcc/testsuite/rust/compile/torture/return_function.rs5
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h
index 27dfe36..4952c9a 100644
--- a/gcc/rust/lint/rust-lint-marklive.h
+++ b/gcc/rust/lint/rust-lint-marklive.h
@@ -119,6 +119,12 @@ public:
function.get_definition ().get ()->accept_vis (*this);
}
+ void visit (HIR::ReturnExpr &expr) override
+ {
+ if (expr.has_return_expr ())
+ expr.get_expr ()->accept_vis (*this);
+ }
+
void visit (HIR::ExprStmtWithoutBlock &stmt) override
{
stmt.get_expr ()->accept_vis (*this);
diff --git a/gcc/testsuite/rust/compile/torture/return_function.rs b/gcc/testsuite/rust/compile/torture/return_function.rs
new file mode 100644
index 0000000..084adaf
--- /dev/null
+++ b/gcc/testsuite/rust/compile/torture/return_function.rs
@@ -0,0 +1,5 @@
+fn foo() {}
+
+fn main() {
+ return foo();
+}