summaryrefslogtreecommitdiff
path: root/source/slang/slang-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-parser.cpp')
-rw-r--r--source/slang/slang-parser.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 40bb91d77..466feecf1 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -2179,10 +2179,36 @@ namespace Slang
}
else if( parser->LookAheadToken("class") )
{
- auto decl = parser->ParseClass();
- typeSpec.decl = decl;
- typeSpec.expr = createDeclRefType(parser, decl);
- return typeSpec;
+ // TODO(JS): Class type doesn't currently have the correct semantics. This is covered here
+ // https://github.com/shader-slang/slang/issues/2206
+ //
+ // For now the use of `class` is disabled.
+ // The remaining code around `class` left intact as likely will be the basis for the future
+ // implementation.
+
+ const bool disableClass = true;
+
+ if (disableClass)
+ {
+ parser->sink->diagnose(parser->tokenReader.peekLoc(), Diagnostics::classIsReservedKeyword);
+
+ // Consume `class`
+ advanceToken(parser);
+
+ // Indicate in recovering state.
+ parser->isRecovering = true;
+
+ // Check to confirm the result is invalid
+ SLANG_ASSERT(typeSpec.decl == nullptr && typeSpec.expr == nullptr);
+ return typeSpec;
+ }
+ else
+ {
+ auto decl = parser->ParseClass();
+ typeSpec.decl = decl;
+ typeSpec.expr = createDeclRefType(parser, decl);
+ return typeSpec;
+ }
}
else if(parser->LookAheadToken("enum"))
{
@@ -2293,6 +2319,11 @@ namespace Slang
Modifiers modifiers = inModifiers;
auto typeSpec = _parseTypeSpec(parser, modifiers);
+ if (typeSpec.expr == nullptr && typeSpec.decl == nullptr)
+ {
+ return nullptr;
+ }
+
// We may need to build up multiple declarations in a group,
// but the common case will be when we have just a single
// declaration