diff options
Diffstat (limited to 'source/slang/slang-check-modifier.cpp')
| -rw-r--r-- | source/slang/slang-check-modifier.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index a9a8c19da..c9800b325 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -999,16 +999,15 @@ namespace Slang } } - bool isModifierAllowedOnDecl(ASTNodeType modifierType, Decl* decl) + bool isModifierAllowedOnDecl(bool isGLSLInput, ASTNodeType modifierType, Decl* decl) { switch (modifierType) { - // Allowed only on parameters and global variables. + // In addition to the above cases, these are also present on empty + // global declarations, for instance + // layout(local_size_x=1) in; case ASTNodeType::InModifier: - case ASTNodeType::OutModifier: case ASTNodeType::InOutModifier: - case ASTNodeType::RefModifier: - case ASTNodeType::ConstRefModifier: case ASTNodeType::GLSLLayoutModifier: case ASTNodeType::GLSLParsedLayoutModifier: case ASTNodeType::GLSLConstantIDLayoutModifier: @@ -1017,6 +1016,16 @@ namespace Slang case ASTNodeType::GLSLLayoutModifierGroupMarker: case ASTNodeType::GLSLLayoutModifierGroupBegin: case ASTNodeType::GLSLLayoutModifierGroupEnd: + // If we are in GLSL mode, also allow these but otherwise fall to + // the regular check + if(isGLSLInput && as<EmptyDecl>(decl) && isGlobalDecl(decl)) + return true; + [[fallthrough]]; + + // Allowed only on parameters and global variables. + case ASTNodeType::OutModifier: + case ASTNodeType::RefModifier: + case ASTNodeType::ConstRefModifier: case ASTNodeType::GLSLBufferModifier: case ASTNodeType::GLSLWriteOnlyModifier: case ASTNodeType::GLSLReadOnlyModifier: @@ -1114,7 +1123,7 @@ namespace Slang if (auto decl = as<Decl>(syntaxNode)) { - if (!isModifierAllowedOnDecl(m->astNodeType, decl)) + if (!isModifierAllowedOnDecl(getLinkage()->getAllowGLSLInput(), m->astNodeType, decl)) { getSink()->diagnose(m, Diagnostics::modifierNotAllowed, m); return m; |
