diff --git a/Test/baseResults/cppBad.vert.out b/Test/baseResults/cppBad.vert.out new file mode 100755 index 00000000..bd7c1416 --- /dev/null +++ b/Test/baseResults/cppBad.vert.out @@ -0,0 +1,20 @@ +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. + + +Shader version: 100 +ERROR: node is still EOpNull! +0:? Linker Objects + + +Linked vertex stage: + +ERROR: Linking vertex stage: Missing entry point: Each stage requires one "void main()" entry point + +Shader version: 100 +ERROR: node is still EOpNull! +0:? Linker Objects + diff --git a/Test/cppBad.vert b/Test/cppBad.vert new file mode 100644 index 00000000..bb1626ea --- /dev/null +++ b/Test/cppBad.vert @@ -0,0 +1,2 @@ +#define m#0# +#if m diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index a400ee8b..7f09a09f 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.1367" +#define GLSLANG_REVISION "SPIRV99.1370" #define GLSLANG_DATE "30-Jul-2016" diff --git a/glslang/MachineIndependent/preprocessor/PpTokens.cpp b/glslang/MachineIndependent/preprocessor/PpTokens.cpp index 7a1a2447..61883c96 100644 --- a/glslang/MachineIndependent/preprocessor/PpTokens.cpp +++ b/glslang/MachineIndependent/preprocessor/PpTokens.cpp @@ -180,14 +180,17 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken) ltoken += 128; switch (ltoken) { case '#': - if (lReadByte(pTok) == '#') { - parseContext.requireProfile(ppToken->loc, ~EEsProfile, "token pasting (##)"); - parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, 0, "token pasting (##)"); - parseContext.error(ppToken->loc, "token pasting not implemented (internal error)", "##", ""); - //return PpAtomPaste; - return ReadToken(pTok, ppToken); - } else - lUnreadByte(pTok); + // Check for ##, unless the current # is the last character + if (pTok->current < pTok->data.size()) { + if (lReadByte(pTok) == '#') { + parseContext.requireProfile(ppToken->loc, ~EEsProfile, "token pasting (##)"); + parseContext.profileRequires(ppToken->loc, ~EEsProfile, 130, 0, "token pasting (##)"); + parseContext.error(ppToken->loc, "token pasting not implemented (internal error)", "##", ""); + //return PpAtomPaste; + return ReadToken(pTok, ppToken); + } else + lUnreadByte(pTok); + } break; case PpAtomConstString: case PpAtomIdentifier: diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index 6f4abef1..7c31df01 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -78,6 +78,7 @@ INSTANTIATE_TEST_CASE_P( "cppSimple.vert", "cppIndent.vert", "cppNest.vert", + "cppBad.vert", "cppComplexExpr.vert", "badChars.frag", "pointCoord.frag",