Skip to content

[HLSL][RootSignature] Incorrectly allows specifying parameters without a comma #147337

@inbelic

Description

@inbelic

This issue tracks fixing a bug that allows parameters to be specified without an intermediate comma.

For instance:

RootFlags(0) CBV(b0)

Should be invalid because there is no comma between the two parameters.

This is because of the code pattern as follows:

if (tryConsumeExpectedToken(TokenKind::kw_RootFlags)) {
auto Flags = parseRootFlags();
if (!Flags.has_value())
return true;
Elements.push_back(*Flags);
}
if (tryConsumeExpectedToken(TokenKind::kw_RootConstants)) {
auto Constants = parseRootConstants();
if (!Constants.has_value())
return true;
Elements.push_back(*Constants);
}

It should be an else-if chain so that if we successfully parse the first element type, it will not attempt to parse any other element types right after.

Reproduction here: https://godbolt.org/z/arcExM9rE

AC:

  • All occurrences of the if chains should be replaced with an else-if chain
  • Add unit tests for this scenario

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions