diff --git a/Test/baseResults/comment.frag.out b/Test/baseResults/comment.frag.out index 0daf7575b7002600d3907ee3cd97782f931f4bfa..c3a548c1b98a78df702d2ecddf55650c0b309919 100644 --- a/Test/baseResults/comment.frag.out +++ b/Test/baseResults/comment.frag.out @@ -1,5 +1,7 @@ comment.frag Warning, version 430 is not yet complete; some version-specific features are present, but many are missing. +WARNING: 0:10: 'line continuation' : used at end of comment; the following line is still part of the comment +WARNING: 0:12: 'line continuation' : used at end of comment; the following line is still part of the comment 0:? Sequence 0:17 Function Definition: main( (void) diff --git a/Test/baseResults/lineContinuation.vert.out b/Test/baseResults/lineContinuation.vert.out index 0982a25e1d2a47a922775577b349304ac05b225b..344099b823f8f7cab6742f9d670e5cc1923ddc64 100644 --- a/Test/baseResults/lineContinuation.vert.out +++ b/Test/baseResults/lineContinuation.vert.out @@ -1,4 +1,5 @@ lineContinuation.vert +WARNING: 0:3: 'line continuation' : used at end of comment; the following line is still part of the comment ERROR: 0:6: '#error' : e1 ERROR: 0:11: '#error' : e2 ERROR: 0:18: '#error' : e3 @@ -25,6 +26,7 @@ ERROR: node is still EOpNull! 0:25 'b' (highp 4-component vector of float) 0:? Linker Objects 0:? 'foo' (highp float) +0:? 'goodDecl' (highp int) 0:? 'gl_VertexID' (gl_VertexId highp int) 0:? 'gl_InstanceID' (gl_InstanceId highp int) diff --git a/Test/baseResults/lineContinuation100.vert.out b/Test/baseResults/lineContinuation100.vert.out index 9e20998c2dbd6fa4813086e96201ea4ae07ee986..75191464b7883c9376d55b56dcf844b67169b524 100644 --- a/Test/baseResults/lineContinuation100.vert.out +++ b/Test/baseResults/lineContinuation100.vert.out @@ -1,6 +1,6 @@ lineContinuation100.vert -ERROR: 0:3: 'line continuation' : not supported for this version or the enabled extensions -ERROR: 0:6: '#error' : e1 +WARNING: 0:3: 'line continuation' : used at end of comment, but this version does not provide line continuation +ERROR: 0:4: '#error' : good error ERROR: 0:8: 'line continuation' : not supported for this version or the enabled extensions ERROR: 0:11: '#error' : e2 ERROR: 0:13: 'line continuation' : not supported for this version or the enabled extensions @@ -8,7 +8,7 @@ ERROR: 0:14: 'line continuation' : not supported for this version or the enabled ERROR: 0:15: 'line continuation' : not supported for this version or the enabled extensions ERROR: 0:18: '#error' : e3 ERROR: 0:24: 'line continuation' : not supported for this version or the enabled extensions -ERROR: 9 compilation errors. No code generated. +ERROR: 8 compilation errors. No code generated. ERROR: node is still EOpNull! diff --git a/Test/lineContinuation.vert b/Test/lineContinuation.vert index 7909bf2513b083a654937395d11a01b8a3d43c4a..a70b625c33fb72b5c7419f24054e44bee2474958 100644 --- a/Test/lineContinuation.vert +++ b/Test/lineContinuation.vert @@ -28,3 +28,9 @@ vec4 foo2(vec4 a) // aoeuntheo unatehutna \ antaehnathe // anteonuth $ natohe " ' // anteonuth natohe + +#define FOO int /* \ +*/ goodDecl; + +FOO + diff --git a/Test/lineContinuation100.vert b/Test/lineContinuation100.vert index 8b164e7b7da2e6ebce963b0b1004cd83939a52b5..b68b715477dc6d11b6b8284cfdd26d81f91ede8d 100644 --- a/Test/lineContinuation100.vert +++ b/Test/lineContinuation100.vert @@ -1,9 +1,9 @@ #version 100 -// this file cont\ -ains no errors other than the #error which are there to see if line numbering for errors is correct +// non-line continuation comment \ +#error good error + -#error e1 float f\ oo; // same as 'float foo;' diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 8d866e5c4bf6d3574b0c3c34f10cbc29f97d596d..396267d04dc682cb4d76206173799ddbbe06589a 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -9,5 +9,5 @@ // source have to figure out how to create revision.h just to get a build // going. However, if it is not updated, it can be a version behind. -#define GLSLANG_REVISION "24390" -#define GLSLANG_DATE "2013/12/06 11:19:22" +#define GLSLANG_REVISION "24391" +#define GLSLANG_DATE "2013/12/06 11:24:47" diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 9d80e3ea0296e77a9edc68ee4a4e8fd3b676f41c..cd15136d9d5d6633caefe0b05cc17417046a2bd3 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -1410,13 +1410,22 @@ void TParseContext::reservedPpErrorCheck(TSourceLoc loc, const char* identifier, // // See if this version/profile allows use of the line-continuation character '\'. // -void TParseContext::lineContinuationCheck(TSourceLoc loc) +bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment) { - if ((profile == EEsProfile && version >= 300) || - (profile != EEsProfile && version >= 420)) - return; - const char* message = "line continuation"; + + bool lineContinuationAllowed = (profile == EEsProfile && version >= 300) || + (profile != EEsProfile && version >= 420); + + if (endOfComment) { + if (lineContinuationAllowed) + warn(loc, "used at end of comment; the following line is still part of the comment", message, ""); + else + warn(loc, "used at end of comment, but this version does not provide line continuation", message, ""); + + return lineContinuationAllowed; + } + if (messages & EShMsgRelaxedErrors) { warn(loc, "not allowed in this version", message, ""); } else { diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index ca4778eeb508e5a190bd023bdaf35d5e9c6c29e9..ddbf0f75bd808cfcdf1b7027d051f0f158fe4aaf 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -76,7 +76,7 @@ public: const char *szExtraInfoFormat, ...); bool reservedErrorCheck(TSourceLoc, const TString&); void reservedPpErrorCheck(TSourceLoc, const char* name, const char* op); - void lineContinuationCheck(TSourceLoc); + bool lineContinuationCheck(TSourceLoc, bool endOfComment); bool builtInName(const TString&); void handlePragma(TSourceLoc, const TVector<TString>&); diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index 30df403776a523ab15f9d7b4d7763e52c539ea75..9214c7fdb93baf58d538e3a427c136226acec4be 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -191,7 +191,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken) mac.body = new TokenStream; while (token != '\n') { if (token == '\\') { - parseContext.lineContinuationCheck(ppToken->loc); + parseContext.lineContinuationCheck(ppToken->loc, false); token = currentInput->scan(this, currentInput, ppToken); if (token == '\n' || token == '\r') token = currentInput->scan(this, currentInput, ppToken); diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp index c62fff0e6c7477639836414840bd42c2cab72a30..d29ac10e441ba8846f9de8bb725035968c5e9739 100644 --- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp +++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp @@ -285,7 +285,7 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken) do { if (ch == '\\') { // escaped character - pp->parseContext.lineContinuationCheck(ppToken->loc); + pp->parseContext.lineContinuationCheck(ppToken->loc, false); ch = pp->currentInput->getch(pp, pp->currentInput, ppToken); if (ch == '\r' || ch == '\n') { int nextch = pp->currentInput->getch(pp, pp->currentInput, ppToken); @@ -641,12 +641,15 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken) // allow an escaped newline, otherwise escapes in comments are meaningless ch = pp->currentInput->getch(pp, pp->currentInput, ppToken); if (ch == '\r' || ch == '\n') { - pp->parseContext.lineContinuationCheck(ppToken->loc); - int nextch = pp->currentInput->getch(pp, pp->currentInput, ppToken); - if (ch == '\r' && nextch == '\n') - ch = pp->currentInput->getch(pp, pp->currentInput, ppToken); - else - ch = nextch; + if (! pp->parseContext.lineContinuationCheck(ppToken->loc, true)) + pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken); + else { + int nextch = pp->currentInput->getch(pp, pp->currentInput, ppToken); + if (ch == '\r' && nextch == '\n') + ch = pp->currentInput->getch(pp, pp->currentInput, ppToken); + else + ch = nextch; + } } } } while (ch != '\n' && ch != EOF); @@ -684,7 +687,7 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken) ch = pp->currentInput->getch(pp, pp->currentInput, ppToken); while (ch != '"' && ch != '\n' && ch != EOF) { if (ch == '\\') { - pp->parseContext.lineContinuationCheck(ppToken->loc); + pp->parseContext.lineContinuationCheck(ppToken->loc, false); ch = pp->currentInput->getch(pp, pp->currentInput, ppToken); if (ch == '\n' || ch == '\r' || ch == EOF) break;