mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56:16 +00:00
validation: structures cannot be empty
Fixed many tests that had empty structures. Change-Id: Id91312afa39a6293426f99d0dd12578dba46aa61 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56621 Auto-Submit: James Price <jrprice@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
d4c64af117
commit
37cabbb468
@@ -359,7 +359,7 @@ using StructDecorationTest = TestWithParams;
|
||||
TEST_P(StructDecorationTest, IsValid) {
|
||||
auto& params = GetParam();
|
||||
|
||||
Structure("mystruct", {},
|
||||
Structure("mystruct", {Member("a", ty.f32())},
|
||||
createDecorations(Source{{12, 34}}, *this, params.kind));
|
||||
|
||||
WrapInFunction();
|
||||
|
||||
@@ -102,12 +102,13 @@ TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Multiple) {
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Struct) {
|
||||
// struct Output {
|
||||
// a : f32;
|
||||
// };
|
||||
// [[stage(vertex)]]
|
||||
// fn main() -> [[location(0)]] Output {
|
||||
// return Output();
|
||||
// }
|
||||
auto* output = Structure("Output", {});
|
||||
auto* output = Structure("Output", {Member("a", ty.f32())});
|
||||
Func(Source{{12, 34}}, "main", {}, ty.Of(output),
|
||||
{Return(Construct(ty.Of(output)))}, {Stage(ast::PipelineStage::kVertex)},
|
||||
{Location(Source{{13, 43}}, 0)});
|
||||
@@ -328,10 +329,11 @@ TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Multiple) {
|
||||
|
||||
TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Struct) {
|
||||
// struct Input {
|
||||
// a : f32;
|
||||
// };
|
||||
// [[stage(fragment)]]
|
||||
// fn main([[location(0)]] param : Input) {}
|
||||
auto* input = Structure("Input", {});
|
||||
auto* input = Structure("Input", {Member("a", ty.f32())});
|
||||
auto* param = Param("param", ty.Of(input), {Location(Source{{13, 43}}, 0)});
|
||||
Func(Source{{12, 34}}, "main", {param}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
@@ -3360,6 +3360,12 @@ bool Resolver::ValidateArrayStrideDecoration(const ast::StrideDecoration* deco,
|
||||
}
|
||||
|
||||
bool Resolver::ValidateStructure(const sem::Struct* str) {
|
||||
if (str->Members().empty()) {
|
||||
AddError("structures must have at least one member",
|
||||
str->Declaration()->source());
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto* member : str->Members()) {
|
||||
if (auto* r = member->Type()->As<sem::Array>()) {
|
||||
if (r->IsRuntimeSized()) {
|
||||
|
||||
Reference in New Issue
Block a user