Skip to content

Commit 21d31c5

Browse files
committed
review: add repeated param error testcase
1 parent 6193124 commit 21d31c5

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingParameterTest) {
401401
ASSERT_TRUE(Consumer->isSatisfied());
402402
}
403403

404-
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryParameterTest) {
404+
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
405405
// This test will check that the parsing fails due the same mandatory
406406
// parameter being specified multiple times
407407
const llvm::StringLiteral Source = R"cc(
@@ -425,6 +425,28 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryParameterTest) {
425425
ASSERT_TRUE(Consumer->isSatisfied());
426426
}
427427

428+
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
429+
// This test will check that the parsing fails due the same mandatory
430+
// parameter being specified multiple times
431+
const llvm::StringLiteral Source = R"cc(
432+
RootConstants(num32BitConstants = 32, num32BitConstants = 24)
433+
)cc";
434+
435+
TrivialModuleLoader ModLoader;
436+
auto PP = createPP(Source, ModLoader);
437+
auto TokLoc = SourceLocation();
438+
439+
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
440+
SmallVector<RootElement> Elements;
441+
hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
442+
443+
// Test correct diagnostic produced
444+
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
445+
ASSERT_TRUE(Parser.parse());
446+
447+
ASSERT_TRUE(Consumer->isSatisfied());
448+
}
449+
428450
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalParameterTest) {
429451
// This test will check that the parsing fails due the same optional
430452
// parameter being specified multiple times

0 commit comments

Comments
 (0)