summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-modifier.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-23 11:25:51 -0700
committerGitHub <noreply@github.com>2024-03-23 11:25:51 -0700
commitc9df734b836a503dbc09c48bfd54b35facd0f105 (patch)
tree165ecf9668e2f25d71e4327dd24c5de7dfd698dc /source/slang/slang-check-modifier.cpp
parenta23adc221b1ea26db3f3313226b629eb9e308b0f (diff)
Allow anonymous struct. (#3822)
Diffstat (limited to 'source/slang/slang-check-modifier.cpp')
-rw-r--r--source/slang/slang-check-modifier.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp
index 17215d284..0b9688cb0 100644
--- a/source/slang/slang-check-modifier.cpp
+++ b/source/slang/slang-check-modifier.cpp
@@ -1176,7 +1176,8 @@ namespace Slang
Modifier* SemanticsVisitor::checkModifier(
Modifier* m,
- ModifiableSyntaxNode* syntaxNode)
+ ModifiableSyntaxNode* syntaxNode,
+ bool ignoreUnallowedModifier)
{
if(auto hlslUncheckedAttribute = as<UncheckedAttribute>(m))
{
@@ -1206,7 +1207,11 @@ namespace Slang
isGLSLInput = true;
if (!isModifierAllowedOnDecl(isGLSLInput, m->astNodeType, decl))
{
- getSink()->diagnose(m, Diagnostics::modifierNotAllowed, m);
+ if (!ignoreUnallowedModifier)
+ {
+ getSink()->diagnose(m, Diagnostics::modifierNotAllowed, m);
+ return nullptr;
+ }
return m;
}
}
@@ -1484,6 +1489,7 @@ namespace Slang
Dictionary<ASTNodeType, Modifier*> mapExclusiveGroupToModifier;
Modifier* modifier = syntaxNode->modifiers.first;
+ bool ignoreUnallowedModifier = false;
while (modifier)
{
// Check if a modifier belonging to the same conflict group is already
@@ -1508,7 +1514,12 @@ namespace Slang
// be to return a single unlinked modifier.
modifier->next = nullptr;
- auto checkedModifier = checkModifier(modifier, syntaxNode);
+ // For any modifiers appears after "SharedModifiers", we will not diagnose
+ // an error if the modifier is not allowed on the declaration.
+ if (as<SharedModifiers>(modifier))
+ ignoreUnallowedModifier = true;
+
+ auto checkedModifier = checkModifier(modifier, syntaxNode, ignoreUnallowedModifier);
if(checkedModifier)
{