Fixed a couple places that missed the error check for #else/#elif after #else.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24378 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-12-05 21:51:40 +00:00
parent 521ca375e0
commit 8e789e8d62
5 changed files with 60 additions and 17 deletions

View File

@ -1,6 +1,12 @@
cppNest.vert
ERROR: 0:144: '#elif' : #elif after #else
ERROR: 0:152: '#else' : #else after #else
ERROR: 0:161: '#elif' : #elif after #else
ERROR: 0:169: '#else' : #else after #else
ERROR: 4 compilation errors. No code generated.
0:? Sequence
ERROR: node is still EOpNull!
0:5 Sequence
0:5 move second child to first child (float)
0:5 'sum' (float)

View File

@ -31,7 +31,7 @@ ERROR: 0:143: '#define' : can't use with built-in names (containing consecutive
ERROR: 0:144: '#define' : can't use with built-in names (containing consecutive underscores)
ERROR: 0:145: '#define' : can't use with built-in names (containing consecutive underscores)
ERROR: 0:148: '#else' : unexpected tokens following directive
ERROR: 0:149: '#else' : #elif after #else
ERROR: 0:149: '#elif' : #elif after #else
ERROR: 0:155: '#else' : unexpected tokens following directive
ERROR: 0:158: '#else' : #else after #else
ERROR: 0:160: '#endif' : unexpected tokens following directive

View File

@ -134,3 +134,39 @@ sum += 600000.0;
#endif
#endif
#endif
// ERROR cases...
#if 0
int;
#else
int;
#elif 1
int;
#endif
#if 0
int;
#else
int;
#else
int;
#endif
#if 0
#if 0
int;
#else
int;
#elif 1
int;
#endif
#if 0
int;
#else
int;
#else
int;
#endif
#endif

View File

@ -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 "24376"
#define GLSLANG_DATE "2013/12/05 13:07:56"
#define GLSLANG_REVISION "24377"
#define GLSLANG_DATE "2013/12/05 13:58:16"

View File

@ -307,11 +307,14 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
--depth;
--ifdepth;
} else if (matchelse && depth == 0) {
if (atom == elseAtom ) {
if (atom == elseAtom) {
elseSeen[elsetracker] = true;
token = extraTokenCheck(atom, ppToken, currentInput->scan(this, currentInput, ppToken));
// found the #else we are looking for
break;
} else if (atom == elifAtom) {
if (elseSeen[elsetracker])
parseContext.error(ppToken->loc, "#elif after #else", "#elif", "");
/* we decrement ifdepth here, because CPPif will increment
* it and we really want to leave it alone */
if (ifdepth) {
@ -330,7 +333,7 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
token = extraTokenCheck(atom, ppToken, currentInput->scan(this, currentInput, ppToken));
} else if (atom == elifAtom) {
if (elseSeen[elsetracker])
parseContext.error(ppToken->loc, "#elif after #else", "#else", "");
parseContext.error(ppToken->loc, "#elif after #else", "#elif", "");
}
}
@ -778,20 +781,18 @@ int TPpContext::readCPPline(TPpToken* ppToken)
if (ppToken->atom == defineAtom) {
token = CPPdefine(ppToken);
} else if (ppToken->atom == elseAtom) {
if (! elsetracker[elseSeen]) {
elsetracker[elseSeen] = true;
if (! ifdepth)
parseContext.error(ppToken->loc, "mismatched statements", "#else", "");
token = extraTokenCheck(elseAtom, ppToken, currentInput->scan(this, currentInput, ppToken));
token = CPPelse(0, ppToken);
} else {
parseContext.error(ppToken->loc, "#else after a #else", "#else", "");
ifdepth = 0;
return 0;
}
if (elsetracker[elseSeen])
parseContext.error(ppToken->loc, "#else after #else", "#else", "");
elsetracker[elseSeen] = true;
if (! ifdepth)
parseContext.error(ppToken->loc, "mismatched statements", "#else", "");
token = extraTokenCheck(elseAtom, ppToken, currentInput->scan(this, currentInput, ppToken));
token = CPPelse(0, ppToken);
} else if (ppToken->atom == elifAtom) {
if (! ifdepth)
parseContext.error(ppToken->loc, "mismatched statements", "#elif", "");
if (elseSeen[elsetracker])
parseContext.error(ppToken->loc, "#elif after #else", "#elif", "");
// this token is really a dont care, but we still need to eat the tokens
token = currentInput->scan(this, currentInput, ppToken);
while (token != '\n')