Skip to content

Commit 853987d

Browse files
authored
Add ParamDecl as the attribute target (shader-slang#4067)
Currently we only allow variable, struct, and function as the target for the user-defined attribute, this change adds the function parameter to the target as well.
1 parent ca62ec2 commit 853987d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

source/slang/core.meta.slang

+1
Original file line numberDiff line numberDiff line change
@@ -2569,6 +2569,7 @@ enum _AttributeTargets
25692569
Struct = $( (int) UserDefinedAttributeTargets::Struct),
25702570
Var = $( (int) UserDefinedAttributeTargets::Var),
25712571
Function = $( (int) UserDefinedAttributeTargets::Function),
2572+
Param = $( (int) UserDefinedAttributeTargets::Param),
25722573
};
25732574
__attributeTarget(StructDecl)
25742575
attribute_syntax [__AttributeUsage(target : _AttributeTargets)] : AttributeUsageAttribute;

source/slang/slang-check-modifier.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ namespace Slang
318318
cls = m_astBuilder->findSyntaxClass(UnownedStringSlice::fromLiteral("FuncDecl"));
319319
return true;
320320
}
321+
if (typeFlags == (int)UserDefinedAttributeTargets::Param)
322+
{
323+
cls = m_astBuilder->findSyntaxClass(UnownedStringSlice::fromLiteral("ParamDecl"));
324+
return true;
325+
}
321326
return false;
322327
}
323328

source/slang/slang-syntax.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ namespace Slang
322322
Struct = 1,
323323
Var = 2,
324324
Function = 4,
325-
All = 7
325+
Param = 8,
326+
All = 0x0F
326327
};
327328

328329
const int kUnsizedArrayMagicLength = 0x7FFFFFFF;

0 commit comments

Comments
 (0)