Commit 11e1a073 by John Kessenich

PP: Fix issue #407; handle empty identifier.

The sequence #define m() int m" creates a token of no length (a string of 0 size). Protect against a string of 0 size as well as the existing protect against a null string.
parent 7208473c
cppBad.vert cppBad.vert
ERROR: 0:2: 'preprocessor evaluation' : bad expression ERROR: 0:2: 'preprocessor evaluation' : bad expression
ERROR: 0:2: '#if' : unexpected tokens following directive ERROR: 0:2: '#if' : unexpected tokens following directive
ERROR: 0:3: '' : missing #endif ERROR: 0:5: 'string' : End of line in string
ERROR: 3 compilation errors. No code generated. ERROR: 0:5: 'macro expansion' : expected '(' following n
ERROR: 0:5: '' : syntax error
ERROR: 5 compilation errors. No code generated.
Shader version: 100 Shader version: 100
......
#define m#0# #define m#0#
#if m #if m
#define n()
int n"
\ No newline at end of file
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "SPIRV99.1373" #define GLSLANG_REVISION "SPIRV99.1374"
#define GLSLANG_DATE "30-Jul-2016" #define GLSLANG_DATE "30-Jul-2016"
...@@ -612,13 +612,15 @@ void TScanContext::deleteKeywordMap() ...@@ -612,13 +612,15 @@ void TScanContext::deleteKeywordMap()
ReservedSet = nullptr; ReservedSet = nullptr;
} }
// Called by yylex to get the next token.
// Returning 0 implies end of input.
int TScanContext::tokenize(TPpContext* pp, TParserToken& token) int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
{ {
do { do {
parserToken = &token; parserToken = &token;
TPpToken ppToken; TPpToken ppToken;
tokenText = pp->tokenize(&ppToken); tokenText = pp->tokenize(&ppToken);
if (tokenText == nullptr) if (tokenText == nullptr || tokenText[0] == 0)
return 0; return 0;
loc = ppToken.loc; loc = ppToken.loc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment