@@ -59,6 +59,11 @@ bool RootSignatureParser::parse() {
59
59
if (!Sampler.has_value ())
60
60
return true ;
61
61
Elements.emplace_back (ElementLoc, *Sampler);
62
+ } else {
63
+ consumeNextToken (); // let diagnostic be at the start of invalid token
64
+ reportDiag (diag::err_hlsl_invalid_param)
65
+ << /* param of*/ TokenKind::kw_RootSignature;
66
+ return true ;
62
67
}
63
68
64
69
// ',' denotes another element, otherwise, expected to be at end of stream
@@ -198,7 +203,7 @@ std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() {
198
203
}
199
204
Descriptor.setDefaultFlags (Version);
200
205
201
- auto Params = parseRootDescriptorParams (ExpectedReg);
206
+ auto Params = parseRootDescriptorParams (DescriptorKind, ExpectedReg);
202
207
if (!Params.has_value ())
203
208
return std::nullopt;
204
209
@@ -261,6 +266,11 @@ std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {
261
266
Visibility = parseShaderVisibility ();
262
267
if (!Visibility.has_value ())
263
268
return std::nullopt;
269
+ } else {
270
+ consumeNextToken (); // let diagnostic be at the start of invalid token
271
+ reportDiag (diag::err_hlsl_invalid_param)
272
+ << /* param of*/ TokenKind::kw_DescriptorTable;
273
+ return std::nullopt;
264
274
}
265
275
266
276
// ',' denotes another element, otherwise, expected to be at ')'
@@ -316,7 +326,7 @@ RootSignatureParser::parseDescriptorTableClause() {
316
326
}
317
327
Clause.setDefaultFlags (Version);
318
328
319
- auto Params = parseDescriptorTableClauseParams (ExpectedReg);
329
+ auto Params = parseDescriptorTableClauseParams (ParamKind, ExpectedReg);
320
330
if (!Params.has_value ())
321
331
return std::nullopt;
322
332
@@ -474,6 +484,11 @@ RootSignatureParser::parseRootConstantParams() {
474
484
if (!Visibility.has_value ())
475
485
return std::nullopt;
476
486
Params.Visibility = Visibility;
487
+ } else {
488
+ consumeNextToken (); // let diagnostic be at the start of invalid token
489
+ reportDiag (diag::err_hlsl_invalid_param)
490
+ << /* param of*/ TokenKind::kw_RootConstants;
491
+ return std::nullopt;
477
492
}
478
493
479
494
// ',' denotes another element, otherwise, expected to be at ')'
@@ -485,7 +500,8 @@ RootSignatureParser::parseRootConstantParams() {
485
500
}
486
501
487
502
std::optional<RootSignatureParser::ParsedRootDescriptorParams>
488
- RootSignatureParser::parseRootDescriptorParams (TokenKind RegType) {
503
+ RootSignatureParser::parseRootDescriptorParams (TokenKind DescKind,
504
+ TokenKind RegType) {
489
505
assert (CurToken.TokKind == TokenKind::pu_l_paren &&
490
506
" Expects to only be invoked starting at given token" );
491
507
@@ -543,6 +559,10 @@ RootSignatureParser::parseRootDescriptorParams(TokenKind RegType) {
543
559
if (!Flags.has_value ())
544
560
return std::nullopt;
545
561
Params.Flags = Flags;
562
+ } else {
563
+ consumeNextToken (); // let diagnostic be at the start of invalid token
564
+ reportDiag (diag::err_hlsl_invalid_param) << /* param of*/ DescKind;
565
+ return std::nullopt;
546
566
}
547
567
548
568
// ',' denotes another element, otherwise, expected to be at ')'
@@ -554,7 +574,8 @@ RootSignatureParser::parseRootDescriptorParams(TokenKind RegType) {
554
574
}
555
575
556
576
std::optional<RootSignatureParser::ParsedClauseParams>
557
- RootSignatureParser::parseDescriptorTableClauseParams (TokenKind RegType) {
577
+ RootSignatureParser::parseDescriptorTableClauseParams (TokenKind ClauseKind,
578
+ TokenKind RegType) {
558
579
assert (CurToken.TokKind == TokenKind::pu_l_paren &&
559
580
" Expects to only be invoked starting at given token" );
560
581
@@ -638,6 +659,10 @@ RootSignatureParser::parseDescriptorTableClauseParams(TokenKind RegType) {
638
659
if (!Flags.has_value ())
639
660
return std::nullopt;
640
661
Params.Flags = Flags;
662
+ } else {
663
+ consumeNextToken (); // let diagnostic be at the start of invalid token
664
+ reportDiag (diag::err_hlsl_invalid_param) << /* param of*/ ClauseKind;
665
+ return std::nullopt;
641
666
}
642
667
643
668
// ',' denotes another element, otherwise, expected to be at ')'
@@ -833,6 +858,11 @@ RootSignatureParser::parseStaticSamplerParams() {
833
858
if (!Visibility.has_value ())
834
859
return std::nullopt;
835
860
Params.Visibility = Visibility;
861
+ } else {
862
+ consumeNextToken (); // let diagnostic be at the start of invalid token
863
+ reportDiag (diag::err_hlsl_invalid_param)
864
+ << /* param of*/ TokenKind::kw_StaticSampler;
865
+ return std::nullopt;
836
866
}
837
867
838
868
// ',' denotes another element, otherwise, expected to be at ')'
0 commit comments