mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 22:23:29 +00:00
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 << ")";
|
out << "builtin(" << builtin->builtin << ")";
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
[&](const ast::DiagnosticAttribute* diagnostic) {
|
||||||
|
return EmitDiagnosticControl(out, diagnostic->control);
|
||||||
|
},
|
||||||
[&](const ast::InterpolateAttribute* interpolate) {
|
[&](const ast::InterpolateAttribute* interpolate) {
|
||||||
out << "interpolate(" << interpolate->type;
|
out << "interpolate(" << interpolate->type;
|
||||||
if (interpolate->sampling != ast::InterpolationSampling::kUndefined) {
|
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
|
||||||
} // namespace tint::writer::wgsl
|
} // namespace tint::writer::wgsl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user