Detect and report multiple #version directives

TRAC #12072 Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@206 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent b41c977b
...@@ -304,7 +304,7 @@ int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseCon ...@@ -304,7 +304,7 @@ int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseCon
cpp->PaArgv = argv; cpp->PaArgv = argv;
cpp->PaArgc = argc; cpp->PaArgc = argc;
cpp->PaStrLen = strLen; cpp->PaStrLen = strLen;
cpp->notAVersionToken = 0; cpp->pastFirstStatement = 0;
yylineno = 1; yylineno = 1;
if (*cpp->PaStrLen >= 0) { if (*cpp->PaStrLen >= 0) {
......
...@@ -78,7 +78,7 @@ struct CPPStruct_Rec { ...@@ -78,7 +78,7 @@ struct CPPStruct_Rec {
int mostRecentToken; // Most recent token seen by the scanner int mostRecentToken; // Most recent token seen by the scanner
InputSrc *currentInput; InputSrc *currentInput;
int previous_token; int previous_token;
int notAVersionToken; // used to make sure that #version is the first token seen in the file, if present int pastFirstStatement; // used to make sure that #version is the first statement seen in the file, if present
void *pC; // storing the parseContext of the compile object in cpp. void *pC; // storing the parseContext of the compile object in cpp.
......
...@@ -638,7 +638,7 @@ static int CPPversion(yystypepp * yylvalpp) ...@@ -638,7 +638,7 @@ static int CPPversion(yystypepp * yylvalpp)
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (cpp->notAVersionToken == 1) if (cpp->pastFirstStatement == 1)
CPPShInfoLogMsg("#version must occur before any other statement in the program"); CPPShInfoLogMsg("#version must occur before any other statement in the program");
if(token=='\n'){ if(token=='\n'){
...@@ -734,7 +734,7 @@ int readCPPline(yystypepp * yylvalpp) ...@@ -734,7 +734,7 @@ int readCPPline(yystypepp * yylvalpp)
}else{ }else{
CPPErrorToInfoLog("#else after a #else"); CPPErrorToInfoLog("#else after a #else");
cpp->ifdepth=0; cpp->ifdepth=0;
cpp->notAVersionToken = 1; cpp->pastFirstStatement = 1;
return 0; return 0;
} }
} else if (yylvalpp->sc_ident == elifAtom) { } else if (yylvalpp->sc_ident == elifAtom) {
...@@ -787,7 +787,7 @@ int readCPPline(yystypepp * yylvalpp) ...@@ -787,7 +787,7 @@ int readCPPline(yystypepp * yylvalpp)
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
} }
cpp->notAVersionToken = !isVersion; cpp->pastFirstStatement = 1;
return token; return token;
} // readCPPline } // readCPPline
......
...@@ -120,7 +120,7 @@ int InitScanner(CPPStruct *cpp) ...@@ -120,7 +120,7 @@ int InitScanner(CPPStruct *cpp)
cpp->currentInput = &eof_inputsrc; cpp->currentInput = &eof_inputsrc;
cpp->previous_token = '\n'; cpp->previous_token = '\n';
cpp->notAVersionToken = 0; cpp->pastFirstStatement = 0;
return 1; return 1;
} // InitScanner } // InitScanner
...@@ -712,7 +712,7 @@ int yylex_CPP(char* buf, int maxSize) ...@@ -712,7 +712,7 @@ int yylex_CPP(char* buf, int maxSize)
cpp->previous_token = token; cpp->previous_token = token;
// expand macros // expand macros
if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) { if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {
cpp->notAVersionToken = 1; cpp->pastFirstStatement = 1;
continue; continue;
} }
...@@ -720,13 +720,13 @@ int yylex_CPP(char* buf, int maxSize) ...@@ -720,13 +720,13 @@ int yylex_CPP(char* buf, int maxSize)
continue; continue;
if (token == CPP_IDENTIFIER) { if (token == CPP_IDENTIFIER) {
cpp->notAVersionToken = 1; cpp->pastFirstStatement = 1;
tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident); tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);
} else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){ } else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){
cpp->notAVersionToken = 1; cpp->pastFirstStatement = 1;
tokenString = yylvalpp.symbol_name; tokenString = yylvalpp.symbol_name;
} else { } else {
cpp->notAVersionToken = 1; cpp->pastFirstStatement = 1;
tokenString = GetStringOfAtom(atable,token); tokenString = GetStringOfAtom(atable,token);
} }
......
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