From 98142ce7cc4522fd9dadba0e458905611e5bacfc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20Poulhi=C3=A8s?= Date: Wed, 26 Apr 2023 23:08:30 +0200 Subject: [PATCH] gccrs: Minor tuning in AST dump MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use parentheses to remove any ambiguities when dumping expressions with unary ! and -. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): print parentheses around unique expression operand. Signed-off-by: Marc Poulhiès --- gcc/rust/ast/rust-ast-dump.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index f8c4f50c27d7..c52de8b6a029 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -554,13 +554,14 @@ Dump::visit (NegationExpr &expr) switch (expr.get_expr_type ()) { case NegationOperator::NEGATE: - stream << '-'; + stream << "-("; break; case NegationOperator::NOT: - stream << '!'; + stream << "!("; break; } visit (expr.get_negated_expr ()); + stream << ')'; } void -- 2.47.2