diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-04 11:58:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 11:58:45 +0000 |
commit | d89c8ccf3237e66029125c0fe007297bb86eca74 (patch) | |
tree | 24926ddec8217cdba774a50eaa06383c8a72d13e /gcc/rust/rust-gcc.cc | |
parent | b4bd389c66a3e3bf0489626a1a70c2500d415ef8 (diff) | |
parent | d6e1771291c792f665f5b9ed7d065bf292051e6a (diff) | |
download | gcc-d89c8ccf3237e66029125c0fe007297bb86eca74.zip gcc-d89c8ccf3237e66029125c0fe007297bb86eca74.tar.gz gcc-d89c8ccf3237e66029125c0fe007297bb86eca74.tar.bz2 |
Merge #990
990: Add must use attribute support r=philberty a=philberty
This is a port of the CPP front-end nodiscard attribute to be used for
must_use. It contains a patch to clean up how we handle expressions vs
statements and removes more of the GCC abstraction. Its my hope that we
can leverage more and more existing code to get the static analysis where
we want it.
Fixes #856
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r-- | gcc/rust/rust-gcc.cc | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 812fd55..dfdfe8a5 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -249,11 +249,9 @@ public: // Statements. - tree expression_statement (tree, tree); - tree init_statement (tree, Bvariable *var, tree init); - tree assignment_statement (tree, tree lhs, tree rhs, Location); + tree assignment_statement (tree lhs, tree rhs, Location); tree return_statement (tree, const std::vector<tree> &, Location); @@ -1837,14 +1835,6 @@ Gcc_backend::call_expression (tree, // containing fcn for call return ret; } -// An expression as a statement. - -tree -Gcc_backend::expression_statement (tree, tree expr) -{ - return expr; -} - // Variable initialization. tree @@ -1880,8 +1870,7 @@ Gcc_backend::init_statement (tree, Bvariable *var, tree init_tree) // Assignment. tree -Gcc_backend::assignment_statement (tree bfn, tree lhs, tree rhs, - Location location) +Gcc_backend::assignment_statement (tree lhs, tree rhs, Location location) { if (lhs == error_mark_node || rhs == error_mark_node) return error_mark_node; @@ -1896,8 +1885,7 @@ Gcc_backend::assignment_statement (tree bfn, tree lhs, tree rhs, || int_size_in_bytes (TREE_TYPE (lhs)) == 0 || TREE_TYPE (rhs) == void_type_node || int_size_in_bytes (TREE_TYPE (rhs)) == 0) - return this->compound_statement (this->expression_statement (bfn, lhs), - this->expression_statement (bfn, rhs)); + return this->compound_statement (lhs, rhs); rhs = this->convert_tree (TREE_TYPE (lhs), rhs, location); @@ -2527,8 +2515,7 @@ Gcc_backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree, if (init_tree != NULL_TREE && (this->type_size (type_tree) == 0 || TREE_TYPE (init_tree) == void_type_node)) - *pstatement = this->compound_statement ( - this->expression_statement (fndecl, init_tree), *pstatement); + *pstatement = this->compound_statement (init_tree, *pstatement); return new Bvariable (var); } |