Made '\' at end of C++ comments be a warning. It is line continuation for some versions, but not others.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24396 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
828dc87a7c
commit
64bcb105c9
10 changed files with 45 additions and 23 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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>&);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue