Commit 52ac67e9 by John Kessenich

Make the PP report an error on undefined macro in "#if ..." for ES profiles,…

Make the PP report an error on undefined macro in "#if ..." for ES profiles, unless relaxed error checking is requested. Still works as normal CPP on non-ES. Also, improved error reporting in general for the PP. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@21417 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 465f4527
...@@ -74,7 +74,7 @@ ShBinding FixedAttributeBindings[] = { ...@@ -74,7 +74,7 @@ ShBinding FixedAttributeBindings[] = {
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings }; ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
static EShLanguage FindLanguage(char *lang); static EShLanguage FindLanguage(char *lang);
bool CompileFile(const char *fileName, ShHandle, int, const TBuiltInResource*); bool CompileFile(const char *fileName, ShHandle, int options, const TBuiltInResource*);
void usage(); void usage();
void FreeFileData(char **data); void FreeFileData(char **data);
char** ReadFileData(const char *fileName); char** ReadFileData(const char *fileName);
...@@ -143,6 +143,9 @@ int C_DECL main(int argc, char* argv[]) ...@@ -143,6 +143,9 @@ int C_DECL main(int argc, char* argv[])
case 'l': case 'l':
debugOptions |= EDebugOpMemoryLeakMode; debugOptions |= EDebugOpMemoryLeakMode;
break; break;
case 'r':
debugOptions |= EDebugOpRelaxedErrors;
break;
case 's': case 's':
debugOptions |= EDebugOpSuppressInfolog; debugOptions |= EDebugOpSuppressInfolog;
break; break;
...@@ -261,9 +264,12 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons ...@@ -261,9 +264,12 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons
if (!data) if (!data)
return false; return false;
EShMessages messages = EShMsgDefault;
if (debugOptions & EDebugOpRelaxedErrors)
messages = (EShMessages)(messages | EShMsgRelaxedErrors);
for (int i = 0; i < ((debugOptions & EDebugOpMemoryLeakMode) ? 100 : 1); ++i) { for (int i = 0; i < ((debugOptions & EDebugOpMemoryLeakMode) ? 100 : 1); ++i) {
for (int j = 0; j < ((debugOptions & EDebugOpMemoryLeakMode) ? 100 : 1); ++j) for (int j = 0; j < ((debugOptions & EDebugOpMemoryLeakMode) ? 100 : 1); ++j)
ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100, false, EShMsgDefault); ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100, false, messages);
#ifdef _WIN32 #ifdef _WIN32
if (debugOptions & EDebugOpMemoryLeakMode) { if (debugOptions & EDebugOpMemoryLeakMode) {
...@@ -290,7 +296,8 @@ void usage() ...@@ -290,7 +296,8 @@ void usage()
"-a: assembly dump (LLVM IR)\n" "-a: assembly dump (LLVM IR)\n"
"-d: delay end (keeps output up in debugger, WIN32)\n" "-d: delay end (keeps output up in debugger, WIN32)\n"
"-l: memory leak mode\n" "-l: memory leak mode\n"
"-s: silent mode (no info log)\n"); "-s: silent mode (no info log)\n"
"-r: relaxed semantic error checking mode\n");
} }
#ifndef _WIN32 #ifndef _WIN32
......
...@@ -32,7 +32,7 @@ sum += 4000.0; ...@@ -32,7 +32,7 @@ sum += 4000.0;
sum += 50000.0; sum += 50000.0;
#endif #endif
#ifndef(OFF) #ifndef OFF
//yes //yes
sum += 600000.0; sum += 600000.0;
#else #else
...@@ -58,6 +58,13 @@ sum += 80000000.0; ...@@ -58,6 +58,13 @@ sum += 80000000.0;
sum += 900000000.0; sum += 900000000.0;
#endif #endif
#if NEVER_DEFINED
//no
sum += 0.04;
#else
sum += 0.05;
#endif
// sum should be 987600301.7 // sum should be 987600301.7
gl_Position = vec4(sum); gl_Position = vec4(sum);
} }
...@@ -951,14 +951,14 @@ int PaParseComment(int& lineno, TParseContext& parseContextLocal) ...@@ -951,14 +951,14 @@ int PaParseComment(int& lineno, TParseContext& parseContextLocal)
extern "C" { extern "C" {
void CPPDebugLogMsg(const char *msg) void ShPpDebugLogMsg(const char *msg)
{ {
TParseContext& pc = *((TParseContext *)cpp->pC); TParseContext& pc = *((TParseContext *)cpp->pC);
pc.infoSink.debug.message(EPrefixNone, msg); pc.infoSink.debug.message(EPrefixNone, msg);
} }
void CPPWarningToInfoLog(const char *msg) void ShPpWarningToInfoLog(const char *msg)
{ {
TParseContext& pc = *((TParseContext *)cpp->pC); TParseContext& pc = *((TParseContext *)cpp->pC);
...@@ -966,20 +966,31 @@ void CPPWarningToInfoLog(const char *msg) ...@@ -966,20 +966,31 @@ void CPPWarningToInfoLog(const char *msg)
pc.infoSink.info.message(EPrefixWarning, msg, yylineno); pc.infoSink.info.message(EPrefixWarning, msg, yylineno);
} }
void CPPShInfoLogMsg(const char *msg) void ShPpErrorToInfoLog(const char *msg)
{ {
TParseContext& pc = *((TParseContext *)cpp->pC); TParseContext& pc = *((TParseContext *)cpp->pC);
pc.error(yylineno,"", "",msg,""); pc.error(yylineno, "", "Preprocessor", msg, "");
GlobalParseContext->recover(); GlobalParseContext->recover();
} }
void CPPErrorToInfoLog(const char *msg) // return 1 if error
// return 0 if no error
int ShPpMacrosMustBeDefinedError()
{ {
TParseContext& pc = *((TParseContext *)cpp->pC); TParseContext& pc = *((TParseContext *)cpp->pC);
pc.error(yylineno, "CPP error:", "", msg, ""); if (pc.profile == EEsProfile) {
GlobalParseContext->recover(); if (pc.messages & EShMsgRelaxedErrors)
ShPpWarningToInfoLog("undefined macro in expression not allowed in es profile");
else {
ShPpErrorToInfoLog("undefined macro in expression");
return 1;
}
}
return 0;
} }
void SetLineNumber(int line) void SetLineNumber(int line)
...@@ -1021,12 +1032,12 @@ void HandlePragma(const char **tokens, int numTokens) ...@@ -1021,12 +1032,12 @@ void HandlePragma(const char **tokens, int numTokens)
if (!strcmp(tokens[0], "optimize")) { if (!strcmp(tokens[0], "optimize")) {
if (numTokens != 4) { if (numTokens != 4) {
CPPShInfoLogMsg("optimize pragma syntax is incorrect"); ShPpErrorToInfoLog("optimize pragma syntax is incorrect");
return; return;
} }
if (strcmp(tokens[1], "(")) { if (strcmp(tokens[1], "(")) {
CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword"); ShPpErrorToInfoLog("\"(\" expected after 'optimize' keyword");
return; return;
} }
...@@ -1035,22 +1046,22 @@ void HandlePragma(const char **tokens, int numTokens) ...@@ -1035,22 +1046,22 @@ void HandlePragma(const char **tokens, int numTokens)
else if (!strcmp(tokens[2], "off")) else if (!strcmp(tokens[2], "off"))
pc.contextPragma.optimize = false; pc.contextPragma.optimize = false;
else { else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma"); ShPpErrorToInfoLog("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
return; return;
} }
if (strcmp(tokens[3], ")")) { if (strcmp(tokens[3], ")")) {
CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma"); ShPpErrorToInfoLog("\")\" expected to end 'optimize' pragma");
return; return;
} }
} else if (!strcmp(tokens[0], "debug")) { } else if (!strcmp(tokens[0], "debug")) {
if (numTokens != 4) { if (numTokens != 4) {
CPPShInfoLogMsg("debug pragma syntax is incorrect"); ShPpErrorToInfoLog("debug pragma syntax is incorrect");
return; return;
} }
if (strcmp(tokens[1], "(")) { if (strcmp(tokens[1], "(")) {
CPPShInfoLogMsg("\"(\" expected after 'debug' keyword"); ShPpErrorToInfoLog("\"(\" expected after 'debug' keyword");
return; return;
} }
...@@ -1059,12 +1070,12 @@ void HandlePragma(const char **tokens, int numTokens) ...@@ -1059,12 +1070,12 @@ void HandlePragma(const char **tokens, int numTokens)
else if (!strcmp(tokens[2], "off")) else if (!strcmp(tokens[2], "off"))
pc.contextPragma.debug = false; pc.contextPragma.debug = false;
else { else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma"); ShPpErrorToInfoLog("\"on\" or \"off\" expected after '(' for 'debug' pragma");
return; return;
} }
if (strcmp(tokens[3], ")")) { if (strcmp(tokens[3], ")")) {
CPPShInfoLogMsg("\")\" expected to end 'debug' pragma"); ShPpErrorToInfoLog("\")\" expected to end 'debug' pragma");
return; return;
} }
} else { } else {
...@@ -1153,7 +1164,7 @@ TBehavior GetBehavior(const char* behavior) ...@@ -1153,7 +1164,7 @@ TBehavior GetBehavior(const char* behavior)
else if (!strcmp("warn", behavior)) else if (!strcmp("warn", behavior))
return EBhWarn; return EBhWarn;
else { else {
CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str()); ShPpErrorToInfoLog((TString("behavior '") + behavior + "' is not supported").c_str());
return EBhDisable; return EBhDisable;
} }
} }
...@@ -1168,7 +1179,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior) ...@@ -1168,7 +1179,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
// special cased for all extension // special cased for all extension
if (!strcmp(extName, "all")) { if (!strcmp(extName, "all")) {
if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) { if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {
CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior"); ShPpErrorToInfoLog("extension 'all' cannot have 'require' or 'enable' behavior");
return; return;
} else { } else {
for (iter = pc.extensionBehavior.begin(); iter != pc.extensionBehavior.end(); ++iter) for (iter = pc.extensionBehavior.begin(); iter != pc.extensionBehavior.end(); ++iter)
...@@ -1179,7 +1190,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior) ...@@ -1179,7 +1190,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
if (iter == pc.extensionBehavior.end()) { if (iter == pc.extensionBehavior.end()) {
switch (behaviorVal) { switch (behaviorVal) {
case EBhRequire: case EBhRequire:
CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str()); ShPpErrorToInfoLog((TString("extension '") + extName + "' is not supported").c_str());
break; break;
case EBhEnable: case EBhEnable:
case EBhWarn: case EBhWarn:
......
...@@ -470,14 +470,14 @@ static int FindHashLoc(AtomTable *atable, const char *s) ...@@ -470,14 +470,14 @@ static int FindHashLoc(AtomTable *atable, const char *s)
char str[200]; char str[200];
sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***", sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",
HASH_TABLE_MAX_COLLISIONS); HASH_TABLE_MAX_COLLISIONS);
CPPShInfoLogMsg(str); ShPpErrorToInfoLog(str);
sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta); sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);
CPPShInfoLogMsg(str); ShPpErrorToInfoLog(str);
for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) { for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) {
sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"", sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",
ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value)); ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));
CPPShInfoLogMsg(str); ShPpErrorToInfoLog(str);
} }
} }
return -1; return -1;
...@@ -720,14 +720,14 @@ void PrintAtomTable(AtomTable *atable) ...@@ -720,14 +720,14 @@ void PrintAtomTable(AtomTable *atable)
for (ii = 0; ii < atable->nextFree; ii++) { for (ii = 0; ii < atable->nextFree; ii++) {
sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]); sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);
CPPDebugLogMsg(str); ShPpDebugLogMsg(str);
} }
sprintf(str, "Hash table: size=%d, entries=%d, collisions=", sprintf(str, "Hash table: size=%d, entries=%d, collisions=",
atable->htable.size, atable->htable.entries); atable->htable.size, atable->htable.entries);
CPPDebugLogMsg(str); ShPpDebugLogMsg(str);
for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) { for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) {
sprintf(str, " %d", atable->htable.counts[ii]); sprintf(str, " %d", atable->htable.counts[ii]);
CPPDebugLogMsg(str); ShPpDebugLogMsg(str);
} }
} // PrintAtomTable } // PrintAtomTable
......
...@@ -102,9 +102,11 @@ int MacroExpand(int atom, yystypepp * yylvalpp); ...@@ -102,9 +102,11 @@ int MacroExpand(int atom, yystypepp * yylvalpp);
extern "C" { extern "C" {
#endif #endif
void CPPDebugLogMsg(const char *msg); // Prints information into debug log void ShPpDebugLogMsg(const char *msg); // Prints information into debug log
void CPPShInfoLogMsg(const char*); // Store cpp Err Msg into Sh.Info.Log void ShPpErrorToInfoLog(const char*); // Store cpp Err Msg into Sh.Info.Log
void CPPWarningToInfoLog(const char *msg); // Prints warning messages into info log void ShPpWarningToInfoLog(const char *msg); // Prints warning messages into info log
int ShPpMacrosMustBeDefinedError();
void HandlePragma(const char**, int numTokens); // #pragma directive container. void HandlePragma(const char**, int numTokens); // #pragma directive container.
void ResetTString(void); // #error Message as TString. void ResetTString(void); // #error Message as TString.
void StoreStr(const char*); // Store the TString in Parse Context. void StoreStr(const char*); // Store the TString in Parse Context.
......
...@@ -258,7 +258,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -258,7 +258,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
} }
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else { } else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG"); ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1; len = 1,str_len=1;
} }
} }
...@@ -268,7 +268,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -268,7 +268,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
if (ch == 'e' || ch == 'E') { if (ch == 'e' || ch == 'E') {
if (len >= MAX_SYMBOL_NAME_LEN) { if (len >= MAX_SYMBOL_NAME_LEN) {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG"); ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1; len = 1,str_len=1;
} else { } else {
ExpSign = 1; ExpSign = 1;
...@@ -289,12 +289,12 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -289,12 +289,12 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
str[len++]=ch; str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else { } else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG"); ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1; len = 1,str_len=1;
} }
} }
} else { } else {
CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT"); ShPpErrorToInfoLog("bad character in exponent");
} }
exp *= ExpSign; exp *= ExpSign;
} }
...@@ -303,7 +303,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -303,7 +303,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
if (len == 0) { if (len == 0) {
yylvalpp->sc_fval = 0.0f; yylvalpp->sc_fval = 0.0f;
yylvalpp->sc_dval = 0.0; yylvalpp->sc_dval = 0.0;
strcpy(str,"0.0"); strcpy(str, "0.0");
} else { } else {
if (ch == 'l' || ch == 'L') { if (ch == 'l' || ch == 'L') {
int ch2 = cpp->currentInput->getch(cpp->currentInput, yylvalpp); int ch2 = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
...@@ -315,7 +315,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -315,7 +315,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
str[len++] = ch; str[len++] = ch;
str[len++] = ch2; str[len++] = ch2;
} else { } else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG"); ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1; len = 1,str_len=1;
} }
} }
...@@ -323,7 +323,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp) ...@@ -323,7 +323,7 @@ static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
if (len < MAX_SYMBOL_NAME_LEN) if (len < MAX_SYMBOL_NAME_LEN)
str[len++] = ch; str[len++] = ch;
else { else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG"); ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1; len = 1,str_len=1;
} }
} else } else
...@@ -425,7 +425,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -425,7 +425,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
ival = (ival << 4) | ii; ival = (ival << 4) | ii;
} else { } else {
if (!AlreadyComplained) if (!AlreadyComplained)
CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW"); ShPpErrorToInfoLog("hexidecimal literal too long");
AlreadyComplained = 1; AlreadyComplained = 1;
} }
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
...@@ -433,7 +433,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -433,7 +433,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
(ch >= 'A' && ch <= 'F') || (ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f')); (ch >= 'a' && ch <= 'f'));
} else { } else {
CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT"); ShPpErrorToInfoLog("bad digit in hexidecimal literal");
} }
if (ch == 'u' || ch == 'U') if (ch == 'u' || ch == 'U')
yylvalpp->symbol_name[len++] = ch; yylvalpp->symbol_name[len++] = ch;
...@@ -452,7 +452,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -452,7 +452,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
ival = (ival << 3) | ii; ival = (ival << 3) | ii;
} else { } else {
if (!AlreadyComplained) if (!AlreadyComplained)
CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW"); ShPpErrorToInfoLog("octal literal too long");
AlreadyComplained = 1; AlreadyComplained = 1;
} }
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
...@@ -496,7 +496,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -496,7 +496,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
ch = yylvalpp->symbol_name[ii] - '0'; ch = yylvalpp->symbol_name[ii] - '0';
if ((ival > 429496729) || (ival == 429496729 && ch >= 6)) { if ((ival > 429496729) || (ival == 429496729 && ch >= 6)) {
if (! AlreadyComplained) if (! AlreadyComplained)
CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW"); ShPpErrorToInfoLog("integral literal too long");
AlreadyComplained = 1; AlreadyComplained = 1;
} }
ival = ival * 10 + ch; ival = ival * 10 + ch;
...@@ -676,14 +676,14 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -676,14 +676,14 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
while (ch != '*') { while (ch != '*') {
if (ch == '\n') nlcount++; if (ch == '\n') nlcount++;
if (ch == EOF) { if (ch == EOF) {
CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT"); ShPpErrorToInfoLog("EOF in comment");
return -1; return -1;
} }
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} }
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp); ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == EOF) { if (ch == EOF) {
CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT"); ShPpErrorToInfoLog("EOF in comment");
return -1; return -1;
} }
} while (ch != '/'); } while (ch != '/');
...@@ -718,7 +718,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -718,7 +718,7 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
yylvalpp->sc_ident = LookUpAddString(atable, string_val); yylvalpp->sc_ident = LookUpAddString(atable, string_val);
return CPP_STRCONSTANT; return CPP_STRCONSTANT;
} else { } else {
CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING"); ShPpErrorToInfoLog("end of line in string");
return ERROR_SY; return ERROR_SY;
} }
} }
...@@ -727,53 +727,53 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp) ...@@ -727,53 +727,53 @@ static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
int yylex_CPP(char* buf, int maxSize) int yylex_CPP(char* buf, int maxSize)
{ {
yystypepp yylvalpp; yystypepp yylvalpp;
int token = '\n'; int token = '\n';
for(;;) { for(;;) {
char* tokenString = 0; char* tokenString = 0;
token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp);
if(check_EOF(token)) if(check_EOF(token))
return 0; return 0;
if (token == '#') { if (token == '#') {
if (cpp->previous_token == '\n'|| cpp->previous_token == 0) { if (cpp->previous_token == '\n'|| cpp->previous_token == 0) {
token = readCPPline(&yylvalpp); token = readCPPline(&yylvalpp);
if(check_EOF(token)) if(check_EOF(token))
return 0; return 0;
continue; continue;
} else { } else {
CPPErrorToInfoLog("preprocessor command must not be preceded by any other statement in that line"); ShPpErrorToInfoLog("preprocessor directive cannot be preceded by another token");
return 0; return 0;
} }
} }
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) == 1) {
cpp->notAVersionToken = 1; cpp->notAVersionToken = 1;
continue; continue;
} }
if (token == '\n') if (token == '\n')
continue; continue;
if (token == CPP_IDENTIFIER) { if (token == CPP_IDENTIFIER) {
cpp->notAVersionToken = 1; cpp->notAVersionToken = 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->notAVersionToken = 1;
tokenString = yylvalpp.symbol_name; tokenString = yylvalpp.symbol_name;
} else { } else {
cpp->notAVersionToken = 1; cpp->notAVersionToken = 1;
tokenString = GetStringOfAtom(atable,token); tokenString = GetStringOfAtom(atable,token);
} }
if (tokenString) { if (tokenString) {
if ((signed)strlen(tokenString) >= maxSize) { if ((signed)strlen(tokenString) >= maxSize) {
cpp->tokensBeforeEOF = 1; cpp->tokensBeforeEOF = 1;
return maxSize; return maxSize;
} else if (strlen(tokenString) > 0) { } else if (strlen(tokenString) > 0) {
strcpy(buf, tokenString); strcpy(buf, tokenString);
cpp->tokensBeforeEOF = 1; cpp->tokensBeforeEOF = 1;
return (int)strlen(tokenString); return (int)strlen(tokenString);
} }
...@@ -790,7 +790,7 @@ int check_EOF(int token) ...@@ -790,7 +790,7 @@ int check_EOF(int token)
{ {
if(token==-1){ if(token==-1){
if(cpp->ifdepth >0){ if(cpp->ifdepth >0){
CPPErrorToInfoLog("#endif missing!! Compilation stopped"); ShPpErrorToInfoLog("missing #endif");
cpp->CompileError=1; cpp->CompileError=1;
} }
return 1; return 1;
......
...@@ -111,7 +111,7 @@ typedef struct InputSrc { ...@@ -111,7 +111,7 @@ typedef struct InputSrc {
int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner. int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner.
int ScanFromString(char *); // Start scanning the input from the string mentioned. int ScanFromString(char *); // Start scanning the input from the string mentioned.
int check_EOF(int); // check if we hit a EOF abruptly int check_EOF(int); // check if we hit a EOF abruptly
void CPPErrorToInfoLog(const char *); // sticking the msg,line into the Shader's.Info.log void ShPpErrorToInfoLog(const char *); // sticking the msg,line into the Shader's.Info.log
void SetLineNumber(int); void SetLineNumber(int);
void SetStringNumber(int); void SetStringNumber(int);
void IncLineNumber(void); void IncLineNumber(void);
......
...@@ -220,7 +220,7 @@ static void lAddToTree(Symbol **fSymbols, Symbol *fSymb) ...@@ -220,7 +220,7 @@ static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
while (lSymb) { while (lSymb) {
lrev = GetReversedAtom(atable, lSymb->name); lrev = GetReversedAtom(atable, lSymb->name);
if (lrev == frev) { if (lrev == frev) {
CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)"); ShPpErrorToInfoLog("GetAtomString(atable, fSymb->name)");
break; break;
} else { } else {
if (lrev > frev) { if (lrev > frev) {
......
...@@ -470,7 +470,7 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) { ...@@ -470,7 +470,7 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
snprintf(str, maxSize, "%c", token); snprintf(str, maxSize, "%c", token);
break; break;
} }
CPPDebugLogMsg(str); ShPpDebugLogMsg(str);
} }
} }
......
...@@ -231,7 +231,8 @@ enum TDebugOptions { ...@@ -231,7 +231,8 @@ enum TDebugOptions {
EDebugOpLinkMaps = 0x008, EDebugOpLinkMaps = 0x008,
EDebugOpSuppressInfolog = 0x010, EDebugOpSuppressInfolog = 0x010,
EDebugOpMemoryLeakMode = 0x020, EDebugOpMemoryLeakMode = 0x020,
EDebugOpTexturePrototypes = 0x040 EDebugOpTexturePrototypes = 0x040,
EDebugOpRelaxedErrors = 0x080
}; };
#ifdef __cplusplus #ifdef __cplusplus
} }
......
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