summaryrefslogtreecommitdiff
path: root/source/slang/parser.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-03-05 17:24:44 -0500
committerGitHub <noreply@github.com>2019-03-05 17:24:44 -0500
commitdcd9e574782b87d6280f1db8ee9ba6dbb7c96c8b (patch)
treedcb900ec86c6454ff2fcbe16dea6512fdec49413 /source/slang/parser.cpp
parent3d5546600fb4c585b6f6f6dcdb5e122698d1225e (diff)
Hotfix/crash invalid vk binding (#875)
* Add diagnostic for vk::binding failure. * Add test for vk::binding failure. * Add the expected output for glsl-layout-define.hlsl * * Copy over initialize expr if available when validating unchecked * Fix unloop - because now it always has one parameter (when before it could have none) * Split vk::binding and layout tests with invalid parameters * Removed the diagnostic for 2 ints expected * Added vk::binding that doesn't specify set in vk-bindings.slang * * Fix typo * Improve comments.
Diffstat (limited to 'source/slang/parser.cpp')
-rw-r--r--source/slang/parser.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp
index 72e682a63..a7ccb7b8a 100644
--- a/source/slang/parser.cpp
+++ b/source/slang/parser.cpp
@@ -91,7 +91,7 @@ namespace Slang
RefPtr<Scope> currentScope;
TokenReader tokenReader;
- DiagnosticSink * sink;
+ DiagnosticSink* sink;
int genericDepth = 0;
// Have we seen any `import` declarations? If so, we need
@@ -819,8 +819,12 @@ namespace Slang
auto keywordToken = advanceToken(parser);
RefPtr<RefObject> parsedObject = syntaxDecl->parseCallback(parser, syntaxDecl->parseUserData);
- auto syntax = as<T>(parsedObject);
+ if (!parsedObject)
+ {
+ return false;
+ }
+ auto syntax = as<T>(parsedObject);
if (syntax)
{
if (!syntax->loc.isValid())
@@ -4440,7 +4444,14 @@ namespace Slang
parser->ReadToken(TokenType::OpAssign);
+ // If the token asked for is not returned found will put in recovering state, and return token found
Token valToken = parser->ReadToken(TokenType::IntegerLiteral);
+ // If wasn't the desired IntegerLiteral return that couldn't parse
+ if (valToken.type != TokenType::IntegerLiteral)
+ {
+ return nullptr;
+ }
+
// Work out the value
auto value = getIntegerLiteralValue(valToken);