From 11e1a073f33be9fdc1ff9194306179e3e60eb770 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Sat, 30 Jul 2016 13:39:52 -0600 Subject: [PATCH] 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. --- Test/baseResults/cppBad.vert.out | 6 ++++-- Test/cppBad.vert | 3 +++ glslang/Include/revision.h | 2 +- glslang/MachineIndependent/Scan.cpp | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Test/baseResults/cppBad.vert.out b/Test/baseResults/cppBad.vert.out index bd7c141..6938af6 100755 --- a/Test/baseResults/cppBad.vert.out +++ b/Test/baseResults/cppBad.vert.out @@ -1,8 +1,10 @@ cppBad.vert ERROR: 0:2: 'preprocessor evaluation' : bad expression ERROR: 0:2: '#if' : unexpected tokens following directive -ERROR: 0:3: '' : missing #endif -ERROR: 3 compilation errors. No code generated. +ERROR: 0:5: 'string' : End of line in string +ERROR: 0:5: 'macro expansion' : expected '(' following n +ERROR: 0:5: '' : syntax error +ERROR: 5 compilation errors. No code generated. Shader version: 100 diff --git a/Test/cppBad.vert b/Test/cppBad.vert index bb1626e..49600f9 100644 --- a/Test/cppBad.vert +++ b/Test/cppBad.vert @@ -1,2 +1,5 @@ #define m#0# #if m + +#define n() +int n" \ No newline at end of file diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 88fc553..2badfd2 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // 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). -#define GLSLANG_REVISION "SPIRV99.1373" +#define GLSLANG_REVISION "SPIRV99.1374" #define GLSLANG_DATE "30-Jul-2016" diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp index 7f60ddc..e297e34 100644 --- a/glslang/MachineIndependent/Scan.cpp +++ b/glslang/MachineIndependent/Scan.cpp @@ -612,13 +612,15 @@ void TScanContext::deleteKeywordMap() ReservedSet = nullptr; } +// Called by yylex to get the next token. +// Returning 0 implies end of input. int TScanContext::tokenize(TPpContext* pp, TParserToken& token) { do { parserToken = &token; TPpToken ppToken; tokenText = pp->tokenize(&ppToken); - if (tokenText == nullptr) + if (tokenText == nullptr || tokenText[0] == 0) return 0; loc = ppToken.loc; -- 2.7.4