From e5d49cf21db7a398afe6cfdb76f6b4a028e9eecb Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 2 May 2024 13:05:18 -0700 Subject: 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. --- source/slang/slang-check-modifier.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source') 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(); - targetModifier->syntaxClass = attrUsageAttr->targetSyntaxClass; - targetModifier->loc = attrUsageAttr->loc; - addModifier(attrDecl, targetModifier); + while(attrUsageAttr) + { + AttributeTargetModifier* targetModifier = m_astBuilder->create(); + targetModifier->syntaxClass = attrUsageAttr->targetSyntaxClass; + targetModifier->loc = attrUsageAttr->loc; + addModifier(attrDecl, targetModifier); + attrUsageAttr = as(attrUsageAttr->next); + } // Every attribute declaration is associated with the type // of syntax nodes it constructs (via reflection/RTTI). -- cgit v1.2.3