tint/writer/wgsl: Handle diagnostic attributes
Bug: tint:1809 Change-Id: Id2176eff808b24bdb0e31c3eb397c32219ed59e7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117570 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
8dd35110c2
commit
75326f88e6
|
@ -797,6 +797,9 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
|
|||
out << "builtin(" << builtin->builtin << ")";
|
||||
return true;
|
||||
},
|
||||
[&](const ast::DiagnosticAttribute* diagnostic) {
|
||||
return EmitDiagnosticControl(out, diagnostic->control);
|
||||
},
|
||||
[&](const ast::InterpolateAttribute* interpolate) {
|
||||
out << "interpolate(" << interpolate->type;
|
||||
if (interpolate->sampling != ast::InterpolationSampling::kUndefined) {
|
||||
|
|
|
@ -30,5 +30,19 @@ TEST_F(WgslGeneratorImplTest, Emit_DiagnosticDirective) {
|
|||
)");
|
||||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_DiagnosticAttribute) {
|
||||
auto* attr =
|
||||
DiagnosticAttribute(ast::DiagnosticSeverity::kError, Expr("chromium_unreachable_code"));
|
||||
Func("foo", {}, ty.void_(), {}, utils::Vector{attr});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate());
|
||||
EXPECT_EQ(gen.result(), R"(@diagnostic(error, chromium_unreachable_code)
|
||||
fn foo() {
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::writer::wgsl
|
||||
|
|
Loading…
Reference in New Issue