aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-06-21 15:56:26 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:46:29 +0100
commit1891acf2bdd0cdce74e53c7c90ddedae47742624 (patch)
tree4634797033d51be6be973b3c1284f15eecd9185e /gcc/rust/ast/rust-ast.cc
parent13557769abc6f575fa9cd994849c20ccf60dda52 (diff)
downloadgcc-1891acf2bdd0cdce74e53c7c90ddedae47742624.zip
gcc-1891acf2bdd0cdce74e53c7c90ddedae47742624.tar.gz
gcc-1891acf2bdd0cdce74e53c7c90ddedae47742624.tar.bz2
gccrs: expand: Change names and document behavior
Change some argument name, as well as some documentation. gcc/rust/ChangeLog: * ast/rust-ast.cc (BlockExpr::normalize_tail_expr): Refactor code and warn about dangling reference. * expand/rust-expand-visitor.cc (expand_stmt_attribute): Document function and change argument names to make those clearer. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-ast.cc')
-rw-r--r--gcc/rust/ast/rust-ast.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 2eac09b..14ad3a0 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -4228,8 +4228,10 @@ BlockExpr::normalize_tail_expr ()
if (!expr)
{
// HACK: try to turn the last statement into a tail expression
- if (statements.size () && statements.back ()->is_expr ())
+ if (!statements.empty () && statements.back ()->is_expr ())
{
+ // Watch out: This reference become invalid when the vector is
+ // modified.
auto &stmt = static_cast<ExprStmt &> (*statements.back ());
if (!stmt.is_semicolon_followed ())