Skip to content

Commit

Permalink
Fix inlined union with field name (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Dec 1, 2022
1 parent d0e90c7 commit 0095344
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CppAst.Tests/TestStructs.cs
Expand Up @@ -191,7 +191,7 @@ struct HelloWorld
Assert.AreEqual(2, cppStruct.Fields.Count);
// Check the union
Assert.AreEqual(string.Empty, cppStruct.Fields[1].Name);
Assert.AreEqual("e", cppStruct.Fields[1].Name);
Assert.IsInstanceOf<CppClass>(cppStruct.Fields[1].Type);
var cppUnion = ((CppClass)cppStruct.Fields[1].Type);
Assert.AreEqual(CppClassKind.Union, ((CppClass)cppStruct.Fields[1].Type).ClassKind);
Expand Down
1 change: 1 addition & 0 deletions src/CppAst/CppModelBuilder.cs
Expand Up @@ -769,6 +769,7 @@ private CppField VisitFieldOrVariable(CppContainerContext containerContext, CXCu
if (previousField != null && previousField.IsAnonymous && ReferenceEquals(previousField.Type, type))
{
cppField = previousField;
cppField.Name = fieldName;
cppField.Offset = cursor.OffsetOfField / 8;
}
else
Expand Down

0 comments on commit 0095344

Please sign in to comment.