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->ifdepth++;
|
||||||
cpp->elsetracker++;
|
cpp->elsetracker++;
|
||||||
} else if (atom == endifAtom) {
|
} else if (atom == endifAtom) {
|
||||||
|
cpp->elsedepth[cpp->elsetracker] = 0;
|
||||||
|
--cpp->elsetracker;
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
// found the #endif we are looking for
|
// found the #endif we are looking for
|
||||||
cpp->elsedepth[cpp->elsetracker] = 0;
|
|
||||||
--cpp->elsetracker;
|
|
||||||
if (cpp->ifdepth)
|
if (cpp->ifdepth)
|
||||||
--cpp->ifdepth;
|
--cpp->ifdepth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--depth;
|
--depth;
|
||||||
--cpp->elsetracker;
|
|
||||||
--cpp->ifdepth;
|
--cpp->ifdepth;
|
||||||
} else if (matchelse && depth == 0) {
|
} else if (matchelse && depth == 0) {
|
||||||
if (atom == elseAtom ) {
|
if (atom == elseAtom ) {
|
||||||
@ -349,6 +348,7 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
|
|||||||
* it and we really want to leave it alone */
|
* it and we really want to leave it alone */
|
||||||
if (cpp->ifdepth) {
|
if (cpp->ifdepth) {
|
||||||
--cpp->ifdepth;
|
--cpp->ifdepth;
|
||||||
|
cpp->elsedepth[cpp->elsetracker] = 0;
|
||||||
--cpp->elsetracker;
|
--cpp->elsetracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
|
|||||||
}
|
}
|
||||||
} else if((atom == elseAtom) && (!ChkCorrectElseNesting())) {
|
} else if((atom == elseAtom) && (!ChkCorrectElseNesting())) {
|
||||||
CPPErrorToInfoLog("#else after a #else");
|
CPPErrorToInfoLog("#else after a #else");
|
||||||
cpp->CompileError=1;
|
cpp->CompileError = 1;
|
||||||
}
|
}
|
||||||
}; // end while
|
}; // end while
|
||||||
|
|
||||||
@ -499,13 +499,14 @@ error:
|
|||||||
return token;
|
return token;
|
||||||
} // eval
|
} // eval
|
||||||
|
|
||||||
static int CPPif(yystypepp * yylvalpp) {
|
static int CPPif(yystypepp * yylvalpp)
|
||||||
|
{
|
||||||
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||||
int res = 0, err = 0;
|
int res = 0, err = 0;
|
||||||
cpp->elsetracker++;
|
cpp->elsetracker++;
|
||||||
if (!cpp->ifdepth++)
|
if (!cpp->ifdepth++)
|
||||||
ifloc = *cpp->tokenLoc;
|
ifloc = *cpp->tokenLoc;
|
||||||
if(cpp->ifdepth >MAX_IF_NESTING){
|
if (cpp->ifdepth > MAX_IF_NESTING){
|
||||||
CPPErrorToInfoLog("max #if nesting depth exceeded");
|
CPPErrorToInfoLog("max #if nesting depth exceeded");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -772,10 +773,10 @@ int readCPPline(yystypepp * yylvalpp)
|
|||||||
if (yylvalpp->sc_ident == defineAtom) {
|
if (yylvalpp->sc_ident == defineAtom) {
|
||||||
token = CPPdefine(yylvalpp);
|
token = CPPdefine(yylvalpp);
|
||||||
} else if (yylvalpp->sc_ident == elseAtom) {
|
} else if (yylvalpp->sc_ident == elseAtom) {
|
||||||
if(ChkCorrectElseNesting()){
|
if (ChkCorrectElseNesting()) {
|
||||||
if (!cpp->ifdepth ){
|
if (! cpp->ifdepth) {
|
||||||
CPPErrorToInfoLog("#else mismatch");
|
CPPErrorToInfoLog("#else mismatch");
|
||||||
cpp->CompileError=1;
|
cpp->CompileError = 1;
|
||||||
}
|
}
|
||||||
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||||
if (token != '\n') {
|
if (token != '\n') {
|
||||||
@ -784,9 +785,9 @@ int readCPPline(yystypepp * yylvalpp)
|
|||||||
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||||
}
|
}
|
||||||
token = CPPelse(0, yylvalpp);
|
token = CPPelse(0, yylvalpp);
|
||||||
}else{
|
} else {
|
||||||
CPPErrorToInfoLog("#else after a #else");
|
CPPErrorToInfoLog("#else after a #else");
|
||||||
cpp->ifdepth=0;
|
cpp->ifdepth = 0;
|
||||||
cpp->notAVersionToken = 1;
|
cpp->notAVersionToken = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -801,7 +802,7 @@ int readCPPline(yystypepp * yylvalpp)
|
|||||||
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
|
||||||
token = CPPelse(0, yylvalpp);
|
token = CPPelse(0, yylvalpp);
|
||||||
} else if (yylvalpp->sc_ident == endifAtom) {
|
} else if (yylvalpp->sc_ident == endifAtom) {
|
||||||
cpp->elsedepth[cpp->elsetracker]=0;
|
cpp->elsedepth[cpp->elsetracker] = 0;
|
||||||
--cpp->elsetracker;
|
--cpp->elsetracker;
|
||||||
if (!cpp->ifdepth){
|
if (!cpp->ifdepth){
|
||||||
CPPErrorToInfoLog("#endif mismatch");
|
CPPErrorToInfoLog("#endif mismatch");
|
||||||
@ -1055,11 +1056,11 @@ int MacroExpand(int atom, yystypepp * yylvalpp)
|
|||||||
|
|
||||||
int ChkCorrectElseNesting(void)
|
int ChkCorrectElseNesting(void)
|
||||||
{
|
{
|
||||||
if(cpp->elsedepth[cpp->elsetracker]==0){
|
if (cpp->elsedepth[cpp->elsetracker] == 0) {
|
||||||
cpp->elsedepth[cpp->elsetracker]=1;
|
cpp->elsedepth[cpp->elsetracker] = 1;
|
||||||
return 1;
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user