[gcc r14-7530] gccrs: Minor tuning in AST dump

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 17:41:55 GMT 2024


https://gcc.gnu.org/g:98142ce7cc4522fd9dadba0e458905611e5bacfc

commit r14-7530-g98142ce7cc4522fd9dadba0e458905611e5bacfc
Author: Marc Poulhiès <dkm@kataplop.net>
Date:   Wed Apr 26 23:08:30 2023 +0200

    gccrs: Minor tuning in AST dump
    
    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 <dkm@kataplop.net>

Diff:
---
 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 f8c4f50c27d..c52de8b6a02 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


More information about the Gcc-cvs mailing list