diff --git a/Cesium.CodeGen.Tests/CodeGenTypeTests.cs b/Cesium.CodeGen.Tests/CodeGenTypeTests.cs index 8a2f14d9..d93e1b10 100644 --- a/Cesium.CodeGen.Tests/CodeGenTypeTests.cs +++ b/Cesium.CodeGen.Tests/CodeGenTypeTests.cs @@ -158,4 +158,9 @@ public Task ArrayDeclaration() => DoTest(@"int main() [Fact] public Task BasicTypeDef() => DoTest(@"typedef int foo; int main(void) { foo x; return 0; }"); + + [Fact] + public Task StructWithArray() => DoTest(@"typedef struct { + int x[4]; +} foo;"); } diff --git a/Cesium.Parser.Tests/ParserTests/DeclarationParserTests.cs b/Cesium.Parser.Tests/ParserTests/DeclarationParserTests.cs index 0ff66bd3..2b286f22 100644 --- a/Cesium.Parser.Tests/ParserTests/DeclarationParserTests.cs +++ b/Cesium.Parser.Tests/ParserTests/DeclarationParserTests.cs @@ -38,4 +38,9 @@ public Task CliImport() => DoDeclarationParserTest(@"__cli_import(""System.Runti [Fact] public Task ComplexFunctionPointerTypeDef() => DoDeclarationParserTest("typedef void (*foo)(uint64_t, const uint32_t*);"); + + [Fact] + public Task StructWithArray() => DoDeclarationParserTest(@"typedef struct { + int x[4]; +} foo;"); } diff --git a/Cesium.Parser.Tests/ParserTests/verified/DeclarationParserTests.StructWithArray.verified.txt b/Cesium.Parser.Tests/ParserTests/verified/DeclarationParserTests.StructWithArray.verified.txt new file mode 100644 index 00000000..8189b2a6 --- /dev/null +++ b/Cesium.Parser.Tests/ParserTests/verified/DeclarationParserTests.StructWithArray.verified.txt @@ -0,0 +1,65 @@ +{ + "$type": "Cesium.Ast.Declaration, Cesium.Ast", + "Specifiers": [ + { + "$type": "Cesium.Ast.StorageClassSpecifier, Cesium.Ast", + "Name": "typedef" + }, + { + "$type": "Cesium.Ast.StructOrUnionSpecifier, Cesium.Ast", + "TypeKind": "Struct", + "Identifier": null, + "StructDeclarations": [ + { + "$type": "Cesium.Ast.StructDeclaration, Cesium.Ast", + "SpecifiersQualifiers": [ + { + "$type": "Cesium.Ast.SimpleTypeSpecifier, Cesium.Ast", + "TypeName": "int" + } + ], + "Declarators": [ + { + "$type": "Cesium.Ast.StructDeclarator, Cesium.Ast", + "Declarator": { + "$type": "Cesium.Ast.Declarator, Cesium.Ast", + "Pointer": null, + "DirectDeclarator": { + "$type": "Cesium.Ast.ArrayDirectDeclarator, Cesium.Ast", + "Base": { + "$type": "Cesium.Ast.IdentifierDirectDeclarator, Cesium.Ast", + "Identifier": "x", + "Base": null + }, + "TypeQualifiers": null, + "Size": { + "$type": "Cesium.Ast.ConstantExpression, Cesium.Ast", + "Constant": { + "Kind": "IntLiteral", + "Text": "4" + } + } + } + } + } + ] + } + ] + } + ], + "InitDeclarators": [ + { + "$type": "Cesium.Ast.InitDeclarator, Cesium.Ast", + "Declarator": { + "$type": "Cesium.Ast.Declarator, Cesium.Ast", + "Pointer": null, + "DirectDeclarator": { + "$type": "Cesium.Ast.IdentifierDirectDeclarator, Cesium.Ast", + "Identifier": "foo", + "Base": null + } + }, + "Initializer": null + } + ] +} \ No newline at end of file