mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-16 12:21:35 +00:00
tint: Make the error message on enable(f16)
more clear
Explicitly call out that enable directives don't take parenthesis instead of saying "invalid extension name". Bug: tint:1620 Change-Id: I124568fdee2fa5bddf1426bed52762a329bd5d9f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96686 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
5716611bf0
commit
a84b9119eb
@ -363,6 +363,10 @@ Maybe<bool> ParserImpl::enable_directive() {
|
|||||||
synchronized_ = true;
|
synchronized_ = true;
|
||||||
next();
|
next();
|
||||||
name = {"f16", t.source()};
|
name = {"f16", t.source()};
|
||||||
|
} else if (t.Is(Token::Type::kParenLeft)){
|
||||||
|
// A common error case is writing `enable(foo);` instead of `enable foo;`.
|
||||||
|
synchronized_ = false;
|
||||||
|
return add_error(t.source(), "enable directives don't take parenthesis");
|
||||||
} else if (handle_error(t)) {
|
} else if (handle_error(t)) {
|
||||||
// The token might itself be an error.
|
// The token might itself be an error.
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
@ -80,6 +80,18 @@ TEST_F(EnableDirectiveTest, MissingEndingSemicolon) {
|
|||||||
EXPECT_EQ(ast.GlobalDeclarations().size(), 0u);
|
EXPECT_EQ(ast.GlobalDeclarations().size(), 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test the special error message when enable are used with parenthesis.
|
||||||
|
TEST_F(EnableDirectiveTest, ParenthesisSpecialCase) {
|
||||||
|
auto p = parser("enable(f16);");
|
||||||
|
p->translation_unit();
|
||||||
|
EXPECT_TRUE(p->has_error());
|
||||||
|
EXPECT_EQ(p->error(), "1:7: enable directives don't take parenthesis");
|
||||||
|
auto program = p->program();
|
||||||
|
auto& ast = program.AST();
|
||||||
|
EXPECT_EQ(ast.Enables().size(), 0u);
|
||||||
|
EXPECT_EQ(ast.GlobalDeclarations().size(), 0u);
|
||||||
|
}
|
||||||
|
|
||||||
// Test using invalid tokens in an enable directive.
|
// Test using invalid tokens in an enable directive.
|
||||||
TEST_F(EnableDirectiveTest, InvalidTokens) {
|
TEST_F(EnableDirectiveTest, InvalidTokens) {
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user