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/backend/rust-compile-expr.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/backend/rust-compile-expr.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index bf47661..6d50c3f 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -63,8 +63,6 @@ CompileExpr::visit (HIR::ArithmeticOrLogicalExpr &expr) void CompileExpr::visit (HIR::CompoundAssignmentExpr &expr) { - fncontext fn = ctx->peek_fn (); - auto op = expr.get_expr_type (); auto lhs = CompileExpr::Compile (expr.get_left_expr ().get (), ctx); auto rhs = CompileExpr::Compile (expr.get_right_expr ().get (), ctx); @@ -82,10 +80,7 @@ CompileExpr::visit (HIR::CompoundAssignmentExpr &expr) = resolve_operator_overload (lang_item_type, expr, lhs, rhs, expr.get_left_expr ().get (), expr.get_right_expr ().get ()); - auto assignment - = ctx->get_backend ()->expression_statement (fn.fndecl, - compound_assignment); - ctx->add_statement (assignment); + ctx->add_statement (compound_assignment); return; } @@ -94,7 +89,7 @@ CompileExpr::visit (HIR::CompoundAssignmentExpr &expr) = ctx->get_backend ()->arithmetic_or_logical_expression (op, lhs, rhs, expr.get_locus ()); tree assignment - = ctx->get_backend ()->assignment_statement (fn.fndecl, lhs, operator_expr, + = ctx->get_backend ()->assignment_statement (lhs, operator_expr, expr.get_locus ()); ctx->add_statement (assignment); } @@ -304,8 +299,10 @@ CompileExpr::visit (HIR::MatchExpr &expr) { tree result_reference = ctx->get_backend ()->var_expression (tmp, arm_locus); - tree assignment = ctx->get_backend ()->assignment_statement ( - fnctx.fndecl, result_reference, kase_expr_tree, arm_locus); + tree assignment + = ctx->get_backend ()->assignment_statement (result_reference, + kase_expr_tree, + arm_locus); ctx->add_statement (assignment); } |