Fix Shader compilation failures with nested #ifdefs

TRAC #12054 Don't exit from CPPelse prematurely. Clear elsedepth when entering a new #if nesting level. Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Author: Andrew Lewycky git-svn-id: https://angleproject.googlecode.com/svn/trunk@214 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 95124346
......@@ -281,10 +281,10 @@ static int CPPelse(int matchelse, yystypepp * yylvalpp)
atom = yylvalpp->sc_ident;
if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){
depth++; cpp->ifdepth++; cpp->elsetracker++;
cpp->elsedepth[cpp->elsetracker] = 0;
}
else if (atom == endifAtom) {
if(--depth<=0){
cpp->elsedepth[cpp->elsetracker]=0;
if(--depth<0){
--cpp->elsetracker;
if (cpp->ifdepth)
--cpp->ifdepth;
......@@ -461,6 +461,7 @@ static int CPPif(yystypepp * yylvalpp) {
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
int res = 0, err = 0;
cpp->elsetracker++;
cpp->elsedepth[cpp->elsetracker] = 0;
if (!cpp->ifdepth++)
ifloc = *cpp->tokenLoc;
if(cpp->ifdepth >MAX_IF_NESTING){
......@@ -489,6 +490,7 @@ static int CPPifdef(int defined, yystypepp * yylvalpp)
return 0;
}
cpp->elsetracker++;
cpp->elsedepth[cpp->elsetracker] = 0;
if (token != CPP_IDENTIFIER) {
defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
} else {
......@@ -748,7 +750,6 @@ 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->elsetracker;
if (!cpp->ifdepth){
CPPErrorToInfoLog("#endif mismatch");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment