diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 11ee9a1a14..fd76e6ea66 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -1728,9 +1728,20 @@ bool GeneratorImpl::EmitIf(ast::IfStatement* stmt) { } bool GeneratorImpl::EmitMemberAccessor(ast::MemberAccessorExpression* expr) { + bool paren_lhs = + !expr->structure() + ->IsAnyOf(); + if (paren_lhs) { + out_ << "("; + } if (!EmitExpression(expr->structure())) { return false; } + if (paren_lhs) { + out_ << ")"; + } out_ << "."; diff --git a/test/bug/tint/749.spvasm.expected.msl b/test/bug/tint/749.spvasm.expected.msl index 5a7c08c2b5..6bd339d73b 100644 --- a/test/bug/tint/749.spvasm.expected.msl +++ b/test/bug/tint/749.spvasm.expected.msl @@ -1 +1 @@ -SKIP: crbug.com/tint/831 +SKIP: crbug.com/tint/833 loop emission is broken diff --git a/test/ptr_ref/load/global/struct_field.spvasm.expected.msl b/test/ptr_ref/load/global/struct_field.spvasm.expected.msl index 5a7c08c2b5..e3352ce09c 100644 --- a/test/ptr_ref/load/global/struct_field.spvasm.expected.msl +++ b/test/ptr_ref/load/global/struct_field.spvasm.expected.msl @@ -1 +1,16 @@ -SKIP: crbug.com/tint/831 +#include + +using namespace metal; +struct S { + int i; +}; + +kernel void tint_symbol() { + thread S tint_symbol_2 = {}; + thread S* const tint_symbol_1 = &(tint_symbol_2); + int i = 0; + int const x_15 = (*(tint_symbol_1)).i; + i = x_15; + return; +} + diff --git a/test/ptr_ref/load/global/struct_field.wgsl.expected.msl b/test/ptr_ref/load/global/struct_field.wgsl.expected.msl index 5a7c08c2b5..cca8c398b9 100644 --- a/test/ptr_ref/load/global/struct_field.wgsl.expected.msl +++ b/test/ptr_ref/load/global/struct_field.wgsl.expected.msl @@ -1 +1,14 @@ -SKIP: crbug.com/tint/831 +#include + +using namespace metal; +struct S { + int i; +}; + +kernel void tint_symbol() { + thread S tint_symbol_2 = {}; + thread S* const tint_symbol_1 = &(tint_symbol_2); + int const i = (*(tint_symbol_1)).i; + return; +} + diff --git a/test/ptr_ref/store/global/struct_field.spvasm.expected.msl b/test/ptr_ref/store/global/struct_field.spvasm.expected.msl index 3bde28121e..f66e91934f 100644 --- a/test/ptr_ref/store/global/struct_field.spvasm.expected.msl +++ b/test/ptr_ref/store/global/struct_field.spvasm.expected.msl @@ -1 +1,14 @@ -SKIP: crbug.com/tint/831 \ No newline at end of file +#include + +using namespace metal; +struct S { + int i; +}; + +kernel void tint_symbol() { + thread S tint_symbol_2 = {}; + thread S* const tint_symbol_1 = &(tint_symbol_2); + (*(tint_symbol_1)).i = 5; + return; +} +