Skip to content

Commit c6c9a12

Browse files
committed
lexer review: let invalid_token error be an unexpected_token error
1 parent 5ca3547 commit c6c9a12

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,26 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
450450
ASSERT_TRUE(Consumer->IsSatisfied());
451451
}
452452

453+
TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) {
454+
const llvm::StringLiteral Source = R"cc(
455+
notAnIdentifier
456+
)cc";
457+
458+
TrivialModuleLoader ModLoader;
459+
auto PP = CreatePP(Source, ModLoader);
460+
auto TokLoc = SourceLocation();
461+
462+
hlsl::RootSignatureLexer Lexer(Source, TokLoc, *PP);
463+
SmallVector<RootElement> Elements;
464+
hlsl::RootSignatureParser Parser(Elements, Lexer, Diags);
465+
466+
// Test correct diagnostic produced - invalid token
467+
Consumer->SetExpected(diag::err_hlsl_rootsig_unexpected_token_kind);
468+
ASSERT_TRUE(Parser.Parse());
469+
470+
ASSERT_TRUE(Consumer->IsSatisfied());
471+
}
472+
453473
TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
454474
const llvm::StringLiteral Source = R"cc(
455475
DescriptorTable(

0 commit comments

Comments
 (0)