Skip to content

Commit 51f06fd

Browse files
committed
Add missing parenthesis when printing a reference to an array
1 parent b92a128 commit 51f06fd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Generator/Generators/C/CppTypePrinter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ public override TypePrinterResult VisitPointerType(PointerType pointer,
141141
var array = pointer.Pointee as ArrayType;
142142
if (array != null && array.QualifiedType.IsConst())
143143
pointeeType.Type = "const " + pointeeType.Type;
144+
145+
var paren = array != null && pointer.Modifier == PointerType.TypeModifier.LVReference;
146+
if (paren)
147+
pointeeType.NamePrefix.Append("(");
144148
pointeeType.NamePrefix.Append(mod);
149+
if (paren)
150+
pointeeType.NameSuffix.Insert(0, ")");
145151

146152
var qual = GetStringQuals(quals, false);
147153
if (!string.IsNullOrEmpty(qual))

0 commit comments

Comments
 (0)