mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-10 04:20:06 +00:00
CPP: Fix stack of previous nested #if/#else/#endif for whether a #else had been seen, which was sometimes cleared and sometimes not, effected later nested #if/#else/#endif #else checks.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20573 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
aab251435b
commit
e25cd0447d
@ -323,16 +323,15 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
|
||||
cpp->ifdepth++;
|
||||
cpp->elsetracker++;
|
||||
} else if (atom == endifAtom) {
|
||||
cpp->elsedepth[cpp->elsetracker] = 0;
|
||||
--cpp->elsetracker;
|
||||
if (depth == 0) {
|
||||
// found the #endif we are looking for
|
||||
cpp->elsedepth[cpp->elsetracker] = 0;
|
||||
--cpp->elsetracker;
|
||||
if (cpp->ifdepth)
|
||||
--cpp->ifdepth;
|
||||
break;
|
||||
}
|
||||
--depth;
|
||||
--cpp->elsetracker;
|
||||
--cpp->ifdepth;
|
||||
} else if (matchelse && depth == 0) {
|
||||
if (atom == elseAtom ) {
|
||||
@ -349,6 +348,7 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
|
||||
* it and we really want to leave it alone */
|
||||
if (cpp->ifdepth) {
|
||||
--cpp->ifdepth;
|
||||
cpp->elsedepth[cpp->elsetracker] = 0;
|
||||
--cpp->elsetracker;
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
|
||||
}
|
||||
} else if((atom == elseAtom) && (!ChkCorrectElseNesting())) {
|
||||
CPPErrorToInfoLog("#else after a #else");
|
||||
cpp->CompileError=1;
|
||||
cpp->CompileError = 1;
|
||||
}
|
||||
}; // end while
|
||||
|
||||
@ -499,13 +499,14 @@ error:
|
||||
return token;
|
||||
} // eval
|
||||
|
||||
static int CPPif(yystypepp * yylvalpp) {
|
||||
static int CPPif(yystypepp * yylvalpp)
|
||||
{
|
||||
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
int res = 0, err = 0;
|
||||
cpp->elsetracker++;
|
||||
if (!cpp->ifdepth++)
|
||||
ifloc = *cpp->tokenLoc;
|
||||
if(cpp->ifdepth >MAX_IF_NESTING){
|
||||
if (cpp->ifdepth > MAX_IF_NESTING){
|
||||
CPPErrorToInfoLog("max #if nesting depth exceeded");
|
||||
return 0;
|
||||
}
|
||||
@ -772,10 +773,10 @@ int readCPPline(yystypepp * yylvalpp)
|
||||
if (yylvalpp->sc_ident == defineAtom) {
|
||||
token = CPPdefine(yylvalpp);
|
||||
} else if (yylvalpp->sc_ident == elseAtom) {
|
||||
if(ChkCorrectElseNesting()){
|
||||
if (!cpp->ifdepth ){
|
||||
if (ChkCorrectElseNesting()) {
|
||||
if (! cpp->ifdepth) {
|
||||
CPPErrorToInfoLog("#else mismatch");
|
||||
cpp->CompileError=1;
|
||||
cpp->CompileError = 1;
|
||||
}
|
||||
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
if (token != '\n') {
|
||||
@ -784,9 +785,9 @@ int readCPPline(yystypepp * yylvalpp)
|
||||
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
}
|
||||
token = CPPelse(0, yylvalpp);
|
||||
}else{
|
||||
} else {
|
||||
CPPErrorToInfoLog("#else after a #else");
|
||||
cpp->ifdepth=0;
|
||||
cpp->ifdepth = 0;
|
||||
cpp->notAVersionToken = 1;
|
||||
return 0;
|
||||
}
|
||||
@ -801,7 +802,7 @@ int readCPPline(yystypepp * yylvalpp)
|
||||
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||
token = CPPelse(0, yylvalpp);
|
||||
} else if (yylvalpp->sc_ident == endifAtom) {
|
||||
cpp->elsedepth[cpp->elsetracker]=0;
|
||||
cpp->elsedepth[cpp->elsetracker] = 0;
|
||||
--cpp->elsetracker;
|
||||
if (!cpp->ifdepth){
|
||||
CPPErrorToInfoLog("#endif mismatch");
|
||||
@ -1055,11 +1056,11 @@ int MacroExpand(int atom, yystypepp * yylvalpp)
|
||||
|
||||
int ChkCorrectElseNesting(void)
|
||||
{
|
||||
if(cpp->elsedepth[cpp->elsetracker]==0){
|
||||
cpp->elsedepth[cpp->elsetracker]=1;
|
||||
return 1;
|
||||
if (cpp->elsedepth[cpp->elsetracker] == 0) {
|
||||
cpp->elsedepth[cpp->elsetracker] = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user