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
diff --git a/src/compiler/glslang.l b/src/compiler/glslang.l
index 7bb2f3b..55571a4 100644
--- a/src/compiler/glslang.l
+++ b/src/compiler/glslang.l
@@ -304,7 +304,7 @@
cpp->PaArgv = argv;
cpp->PaArgc = argc;
cpp->PaStrLen = strLen;
- cpp->notAVersionToken = 0;
+ cpp->pastFirstStatement = 0;
yylineno = 1;
if (*cpp->PaStrLen >= 0) {
diff --git a/src/compiler/preprocessor/compile.h b/src/compiler/preprocessor/compile.h
index 9e87afc..a40b99e 100644
--- a/src/compiler/preprocessor/compile.h
+++ b/src/compiler/preprocessor/compile.h
@@ -78,7 +78,7 @@
int mostRecentToken; // Most recent token seen by the scanner
InputSrc *currentInput;
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.
diff --git a/src/compiler/preprocessor/cpp.c b/src/compiler/preprocessor/cpp.c
index 92e8443..beb895a 100644
--- a/src/compiler/preprocessor/cpp.c
+++ b/src/compiler/preprocessor/cpp.c
@@ -638,7 +638,7 @@
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");
if(token=='\n'){
@@ -734,7 +734,7 @@
}else{
CPPErrorToInfoLog("#else after a #else");
cpp->ifdepth=0;
- cpp->notAVersionToken = 1;
+ cpp->pastFirstStatement = 1;
return 0;
}
} else if (yylvalpp->sc_ident == elifAtom) {
@@ -787,7 +787,7 @@
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
- cpp->notAVersionToken = !isVersion;
+ cpp->pastFirstStatement = 1;
return token;
} // readCPPline
diff --git a/src/compiler/preprocessor/scanner.c b/src/compiler/preprocessor/scanner.c
index 16dfb94..6645750 100644
--- a/src/compiler/preprocessor/scanner.c
+++ b/src/compiler/preprocessor/scanner.c
@@ -120,7 +120,7 @@
cpp->currentInput = &eof_inputsrc;
cpp->previous_token = '\n';
- cpp->notAVersionToken = 0;
+ cpp->pastFirstStatement = 0;
return 1;
} // InitScanner
@@ -712,7 +712,7 @@
cpp->previous_token = token;
// expand macros
if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {
- cpp->notAVersionToken = 1;
+ cpp->pastFirstStatement = 1;
continue;
}
@@ -720,13 +720,13 @@
continue;
if (token == CPP_IDENTIFIER) {
- cpp->notAVersionToken = 1;
+ cpp->pastFirstStatement = 1;
tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);
} else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){
- cpp->notAVersionToken = 1;
+ cpp->pastFirstStatement = 1;
tokenString = yylvalpp.symbol_name;
} else {
- cpp->notAVersionToken = 1;
+ cpp->pastFirstStatement = 1;
tokenString = GetStringOfAtom(atable,token);
}