Skip to content

[HLSL] Add concept expressions to validate StructuredBuffer element types #117406

@bob80905

Description

@bob80905

Raw buffer resources, like StructuredBuffer, need concept decls so that their element types can be validated. The concepts need to use the negation of the is_intangible builtin, that should be a sufficient condition to impose on element types.
Tests need to be added. This issue is resolved when there are tests that show that raw buffers with invalid element types fail at compile time.
The infrastructure has all been added, all that's needed is another function, like constructTypedBufferConstraintExpr, but for raw buffers. It needs to be passed as an argument to the forward declarations of the relevant buffers, in the addSimpleTemplateParams function, just like constructTypedBufferConstraintExpr's return value was. The content should be just like constructTypedBufferConstraintExpr, except the constraint expression should, instead of using the typed element compatible builtin, use __is_intangible, and then add a Unary expression that negates the result.

Note: also consider the case where sizeof(T) == 0. This should be rejected!

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions