diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2024-05-02 13:05:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-02 13:05:18 -0700 |
| commit | e5d49cf21db7a398afe6cfdb76f6b4a028e9eecb (patch) | |
| tree | cbf120740771f332b1b8f61eacee01b85628465c /source | |
| parent | f7d54af67e026feb2546af1deaf2513a36f8516e (diff) | |
Allow multiple _AttributeTargets for attribute declaration (#4087)
The syntax like:
[__AttributeUsage(_AttributeTargets.Var)]
[__AttributeUsage(_AttributeTargets.Param)]
struct DefaultValueAttribute
{
int iParam;
};
is allowed.
For user-defined attribute, we can specify more attribute targets on the
attribute declaration. So one attribute can be used in more than one
situations.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-modifier.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index 56d905063..b8ff1a116 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -212,10 +212,14 @@ namespace Slang attrDecl->nameAndLoc.loc = structDecl->nameAndLoc.loc; attrDecl->loc = structDecl->loc; - AttributeTargetModifier* targetModifier = m_astBuilder->create<AttributeTargetModifier>(); - targetModifier->syntaxClass = attrUsageAttr->targetSyntaxClass; - targetModifier->loc = attrUsageAttr->loc; - addModifier(attrDecl, targetModifier); + while(attrUsageAttr) + { + AttributeTargetModifier* targetModifier = m_astBuilder->create<AttributeTargetModifier>(); + targetModifier->syntaxClass = attrUsageAttr->targetSyntaxClass; + targetModifier->loc = attrUsageAttr->loc; + addModifier(attrDecl, targetModifier); + attrUsageAttr = as<AttributeUsageAttribute>(attrUsageAttr->next); + } // Every attribute declaration is associated with the type // of syntax nodes it constructs (via reflection/RTTI). |
