[Sema] Allow int arguments for attributes to be enum values (#6353)
The SPIR-V backend uses `ValidateAttributeIntArg` for the `vk::ext_builtin_input` and `vk::ext_builtin_output` attrs, as well as some others. It is convenient for users to be able to pass in an enum value to this attribute, for example: ``` enum class BuiltIn { HelperInvocation = 23 }; [[vk::ext_builtin_input(BuiltIn::HelperInvocation)]] static const bool gl_HelperInvocation; ``` Fixes #6337
This commit is contained in:
Родитель
fdbecd30f8
Коммит
1a48b86e08
|
@ -12334,7 +12334,7 @@ static int ValidateAttributeIntArg(Sema &S, const AttributeList &Attr,
|
|||
} else {
|
||||
if (ArgNum.isInt()) {
|
||||
value = ArgNum.getInt().getSExtValue();
|
||||
if (!(E->getType()->isIntegralType(S.Context)) || value < 0) {
|
||||
if (!(E->getType()->isIntegralOrEnumerationType()) || value < 0) {
|
||||
S.Diag(Attr.getLoc(), diag::warn_hlsl_attribute_expects_uint_literal)
|
||||
<< Attr.getName();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// RUN: %dxc -T cs_6_0 -E main -fcgl %s -spirv -verify
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
enum class BuiltIn {
|
||||
HelperInvocation = 23
|
||||
};
|
||||
|
||||
[[vk::ext_builtin_input(BuiltIn::HelperInvocation)]]
|
||||
static const bool gl_HelperInvocation;
|
||||
|
||||
uint square_x(uint3 v) {
|
||||
return v.x * v.x;
|
||||
}
|
||||
|
||||
[numthreads(32,1,1)]
|
||||
void main() {
|
||||
}
|
Загрузка…
Ссылка в новой задаче