Skip to content

Commit 18af0dd

Browse files
committed
review: add repeated optional error test
1 parent f801180 commit 18af0dd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryParameterTest) {
431431
ASSERT_TRUE(Consumer->isSatisfied());
432432
}
433433

434-
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalParameterTest) {
434+
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest) {
435435
// This test will check that the parsing fails due the same optional
436436
// parameter being specified multiple times
437437
const llvm::StringLiteral Source = R"cc(
@@ -455,6 +455,32 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalParameterTest) {
455455
ASSERT_TRUE(Consumer->isSatisfied());
456456
}
457457

458+
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) {
459+
// This test will check that the parsing fails due the same optional
460+
// parameter being specified multiple times
461+
const llvm::StringLiteral Source = R"cc(
462+
RootConstants(
463+
visibility = Shader_Visibility_All,
464+
b0, num32BitConstants = 1,
465+
visibility = Shader_Visibility_Pixel
466+
)
467+
)cc";
468+
469+
TrivialModuleLoader ModLoader;
470+
auto PP = createPP(Source, ModLoader);
471+
auto TokLoc = SourceLocation();
472+
473+
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
474+
SmallVector<RootElement> Elements;
475+
hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
476+
477+
// Test correct diagnostic produced
478+
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
479+
ASSERT_TRUE(Parser.parse());
480+
481+
ASSERT_TRUE(Consumer->isSatisfied());
482+
}
483+
458484
TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
459485
// This test will check that the lexing fails due to an integer overflow
460486
const llvm::StringLiteral Source = R"cc(

0 commit comments

Comments
 (0)