Skip to content

Commit 0095344

Browse files
committed
Fix inlined union with field name (#67)
1 parent d0e90c7 commit 0095344

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/CppAst.Tests/TestStructs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ struct HelloWorld
191191
Assert.AreEqual(2, cppStruct.Fields.Count);
192192

193193
// Check the union
194-
Assert.AreEqual(string.Empty, cppStruct.Fields[1].Name);
194+
Assert.AreEqual("e", cppStruct.Fields[1].Name);
195195
Assert.IsInstanceOf<CppClass>(cppStruct.Fields[1].Type);
196196
var cppUnion = ((CppClass)cppStruct.Fields[1].Type);
197197
Assert.AreEqual(CppClassKind.Union, ((CppClass)cppStruct.Fields[1].Type).ClassKind);

src/CppAst/CppModelBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ private CppField VisitFieldOrVariable(CppContainerContext containerContext, CXCu
769769
if (previousField != null && previousField.IsAnonymous && ReferenceEquals(previousField.Type, type))
770770
{
771771
cppField = previousField;
772+
cppField.Name = fieldName;
772773
cppField.Offset = cursor.OffsetOfField / 8;
773774
}
774775
else

0 commit comments

Comments
 (0)