[vala/staging] codewriter: Wrap AddressofExpression and PointerIndirection in parens
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codewriter: Wrap AddressofExpression and PointerIndirection in parens
- Date: Mon, 21 Dec 2020 12:53:19 +0000 (UTC)
commit 60f257854f2ed0f2fd24101112fd75b65494572b
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Dec 21 13:52:54 2020 +0100
codewriter: Wrap AddressofExpression and PointerIndirection in parens
vala/valaaddressofexpression.vala | 2 +-
vala/valacodewriter.vala | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/vala/valaaddressofexpression.vala b/vala/valaaddressofexpression.vala
index 0f3233422..d271d0cc4 100644
--- a/vala/valaaddressofexpression.vala
+++ b/vala/valaaddressofexpression.vala
@@ -65,7 +65,7 @@ public class Vala.AddressofExpression : Expression {
}
public override string to_string () {
- return "&" + inner.to_string ();
+ return "(&%s)".printf (inner.to_string ());
}
public override void replace_expression (Expression old_node, Expression new_node) {
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index f555b7a02..cc2196347 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -1424,13 +1424,15 @@ public class Vala.CodeWriter : CodeVisitor {
}
public override void visit_pointer_indirection (PointerIndirection expr) {
- write_string ("*");
+ write_string ("(*");
expr.inner.accept (this);
+ write_string (")");
}
public override void visit_addressof_expression (AddressofExpression expr) {
- write_string ("&");
+ write_string ("(&");
expr.inner.accept (this);
+ write_string (")");
}
public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]