Skip to content

Commit 93e0bdb

Browse files
demangle: always print parentheses for __alignof__ argument
Also update to current demangle-expected from GCC trunk.
1 parent 5f34a24 commit 93e0bdb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ast.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,11 @@ func (u *Unary) print(ps *printState) {
20822082
ps.writeByte('(')
20832083
ps.print(expr)
20842084
ps.writeByte(')')
2085+
} else if op, ok := u.Op.(*Operator); ok && op.Name == "__alignof__" {
2086+
// Always use parentheses for __alignof__ argument.
2087+
ps.writeByte('(')
2088+
ps.print(expr)
2089+
ps.writeByte(')')
20852090
} else {
20862091
parenthesize(ps, expr)
20872092
}

testdata/demangle-expected

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,3 +1469,22 @@ f(A<X{.a.b[3 ... 4]=(1)}>)
14691469
# PR 96143
14701470
_Z2F2IZ1FvEUlvE_EN1AIT_E1XES2_
14711471
A<F()::{lambda()#1}>::X F2<F()::{lambda()#1}>(F()::{lambda()#1})
1472+
1473+
# PR 88115
1474+
_Z1fIiEvDTv111__alignof__T_E
1475+
void f<int>(decltype (__alignof__(int)))
1476+
1477+
_Z1fIiEvDTv111__alignof__tlT_EE
1478+
void f<int>(decltype (__alignof__(int{})))
1479+
1480+
_Z1gI1AEv1SIXadsrT_oncviEE
1481+
void g<A>(S<&A::operator int>)
1482+
1483+
_Z1jI1AEDTcldtfp_oncvPT_EES1_
1484+
decltype (({parm#1}.(operator A*))()) j<A>(A)
1485+
1486+
_Z1fI1AEDtdtfp_srT_1xES1_
1487+
decltype ({parm#1}.A::x) f<A>(A)
1488+
1489+
_Z2f6IP1AEDtptfp_gssr1A1BE1xET_
1490+
decltype ({parm#1}->(::A::B::x)) f6<A*>(A*)

0 commit comments

Comments
 (0)