Skip to content

Commit 1a4d7ae

Browse files
ParseType: skip attributes
1 parent 9397dde commit 1a4d7ae

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

Common/interface/ParsingTools.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ struct TypeDesc
13711371
/// Member name.
13721372
TokenIterType Name = {};
13731373

1374-
/// Semantics (if any).
1374+
/// Semantics (e.g. `float4 position : POSITION;`), if any.
13751375
std::optional<TokenIterType> Semantics = {};
13761376

13771377
/// Array dimensions (if the member is an array).
@@ -1511,9 +1511,17 @@ TypeDesc<TokenIterType> ParseType(const TokenIterType& Start, const TokenIterTyp
15111511
return {};
15121512
}
15131513

1514-
// int i[10];
1515-
// ^
1516-
Type.Members.back().ArrayDimensions.push_back(Token);
1514+
if (Token->GetType() == TokenType::OpenSquareBracket)
1515+
{
1516+
// float4 position [[position]];
1517+
// ^
1518+
}
1519+
else
1520+
{
1521+
// int i[10];
1522+
// ^
1523+
Type.Members.back().ArrayDimensions.push_back(Token);
1524+
}
15171525
Token = ClosingSquareBracket;
15181526
// int i[10];
15191527
// ^

Tests/DiligentCoreTest/src/Common/ParsingToolsTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,19 @@ TEST(Common_ParsingTools, ParseType)
19331933
{"texture3D < float , access :: read >", "tex6", {"5", "6"}, "TEX6"},
19341934
},
19351935
});
1936+
1937+
Test(R"(struct TestStruct
1938+
{
1939+
float4 position[[position]];
1940+
float2 uv[[id(0)]];
1941+
})",
1942+
{
1943+
"TestStruct",
1944+
{
1945+
{"float4", "position"},
1946+
{"float2", "uv"},
1947+
},
1948+
});
19361949
}
19371950

19381951
} // namespace

0 commit comments

Comments
 (0)