Commit 37827023 by John Kessenich

Add warning-suppression flag. Combined with relaxed errors, so an enum can be…

Add warning-suppression flag. Combined with relaxed errors, so an enum can be used instead of many bools. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20818 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 4055816b
...@@ -259,7 +259,7 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons ...@@ -259,7 +259,7 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons
for (int i = 0; i < 1000; ++i) { for (int i = 0; i < 1000; ++i) {
for (int j = 0; j < 100; ++j) for (int j = 0; j < 100; ++j)
#endif #endif
ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100, false, false); ret = ShCompile(compiler, data, OutputMultipleStrings, EShOptNone, resources, debugOptions, 100, false, EShMsgDefault);
#ifdef MEASURE_MEMORY #ifdef MEASURE_MEMORY
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)); GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
......
...@@ -40,11 +40,11 @@ ...@@ -40,11 +40,11 @@
#include <stdarg.h> #include <stdarg.h>
TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, EProfile p, EShLanguage L, TInfoSink& is, TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, EProfile p, EShLanguage L, TInfoSink& is,
bool fc, bool rc) : bool fc, EShMessages m) :
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
switchNestingLevel(0), inTypeParen(false), switchNestingLevel(0), inTypeParen(false),
version(v), profile(p), forwardCompatible(fc), relaxedChecking(rc), version(v), profile(p), forwardCompatible(fc), messages(m),
contextPragma(true, false) contextPragma(true, false)
{ {
for (int type = 0; type < EbtNumTypes; ++type) for (int type = 0; type < EbtNumTypes; ++type)
......
...@@ -68,7 +68,7 @@ struct TPragma { ...@@ -68,7 +68,7 @@ struct TPragma {
// //
struct TParseContext { struct TParseContext {
TParseContext(TSymbolTable&, TIntermediate&, int version, EProfile, EShLanguage, TInfoSink&, TParseContext(TSymbolTable&, TIntermediate&, int version, EProfile, EShLanguage, TInfoSink&,
bool forwardCompatible = false, bool relaxedChecking = false); bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
TIntermediate& intermediate; // to hold and build a parse tree TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
TInfoSink& infoSink; TInfoSink& infoSink;
...@@ -86,7 +86,7 @@ struct TParseContext { ...@@ -86,7 +86,7 @@ struct TParseContext {
int version; // version, updated by #version in the shader int version; // version, updated by #version in the shader
EProfile profile; // the declared profile in the shader (core by default) EProfile profile; // the declared profile in the shader (core by default)
bool forwardCompatible; // true if errors are to be given for use of deprecated features bool forwardCompatible; // true if errors are to be given for use of deprecated features
bool relaxedChecking; // suppress warnings and reduce error checking EShMessages messages; // errors/warnings
bool futureCompatibility; // true if requesting errors for future compatibility (false by default) bool futureCompatibility; // true if requesting errors for future compatibility (false by default)
TMap<TString, TBehavior> extensionBehavior; // for each extension string, what it's current enablement is TMap<TString, TBehavior> extensionBehavior; // for each extension string, what it's current enablement is
......
...@@ -484,7 +484,7 @@ int ShCompile( ...@@ -484,7 +484,7 @@ int ShCompile(
int debugOptions, int debugOptions,
int defaultVersion, // use 100 for ES environment, 110 for desktop int defaultVersion, // use 100 for ES environment, 110 for desktop
bool forwardCompatible, // give errors for use of deprecated features bool forwardCompatible, // give errors for use of deprecated features
bool relaxedChecking // no warnings, reduced errors EShMessages messages // warnings/errors
) )
{ {
if (!InitThread()) if (!InitThread())
...@@ -522,7 +522,7 @@ int ShCompile( ...@@ -522,7 +522,7 @@ int ShCompile(
// they get popped again further down. // they get popped again further down.
AddContextSpecificSymbols(resources, compiler->infoSink, &symbolTable, version, profile, compiler->getLanguage()); AddContextSpecificSymbols(resources, compiler->infoSink, &symbolTable, version, profile, compiler->getLanguage());
TParseContext parseContext(symbolTable, intermediate, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, relaxedChecking); TParseContext parseContext(symbolTable, intermediate, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
if (! goodProfile) if (! goodProfile)
parseContext.error(1, "incorrect", "#version", ""); parseContext.error(1, "incorrect", "#version", "");
......
...@@ -135,7 +135,7 @@ void TParseContext::checkDeprecated(int line, EProfile callingProfile, int depVe ...@@ -135,7 +135,7 @@ void TParseContext::checkDeprecated(int line, EProfile callingProfile, int depVe
if (forwardCompatible) { if (forwardCompatible) {
error(line, "deprecated, may be removed in future release", featureDesc, ""); error(line, "deprecated, may be removed in future release", featureDesc, "");
recover(); recover();
} else if (! relaxedChecking) { } else if (! (messages & EShMsgSuppressWarnings)) {
infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " + infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " +
String(depVersion) + "; may be removed in future release").c_str(), line); String(depVersion) + "; may be removed in future release").c_str(), line);
} }
......
...@@ -572,7 +572,7 @@ int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* te ...@@ -572,7 +572,7 @@ int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* te
pyylval->lex.line = line; pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text); pyylval->lex.string = NewPoolTString(text);
if (pc.futureCompatibility) { if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {
pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);
pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno); pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno);
} }
...@@ -586,7 +586,7 @@ int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char* ...@@ -586,7 +586,7 @@ int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char*
pc.profile != EEsProfile && pc.version < version) { pc.profile != EEsProfile && pc.version < version) {
pyylval->lex.line = yylineno; pyylval->lex.line = yylineno;
pyylval->lex.string = NewPoolTString(yytext); pyylval->lex.string = NewPoolTString(yytext);
if (pc.futureCompatibility) { if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {
pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);
pc.infoSink.info.message(EPrefixWarning, "future reserved word in ES 300 and keyword in GLSL", yylineno); pc.infoSink.info.message(EPrefixWarning, "future reserved word in ES 300 and keyword in GLSL", yylineno);
} }
...@@ -609,7 +609,7 @@ int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* p ...@@ -609,7 +609,7 @@ int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* p
pyylval->lex.line = line; pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text); pyylval->lex.string = NewPoolTString(text);
if (pc.futureCompatibility) { if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {
pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);
pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno); pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno);
} }
...@@ -624,7 +624,7 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in ...@@ -624,7 +624,7 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in
pyylval->lex.line = line; pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text); pyylval->lex.string = NewPoolTString(text);
if (pc.futureCompatibility) { if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {
pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);
pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno); pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno);
} }
...@@ -644,7 +644,7 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int ...@@ -644,7 +644,7 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int
pyylval->lex.line = line; pyylval->lex.line = line;
pyylval->lex.string = NewPoolTString(text); pyylval->lex.string = NewPoolTString(text);
if (pc.futureCompatibility) { if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {
pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno); pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);
pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno); pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno);
} }
...@@ -695,7 +695,7 @@ void CPPWarningToInfoLog(const char *msg) ...@@ -695,7 +695,7 @@ void CPPWarningToInfoLog(const char *msg)
{ {
TParseContext& pc = *((TParseContext *)cpp->pC); TParseContext& pc = *((TParseContext *)cpp->pC);
if (! pc.relaxedChecking) if (! (pc.messages & EShMsgSuppressWarnings))
pc.infoSink.info.message(EPrefixWarning, msg, yylineno); pc.infoSink.info.message(EPrefixWarning, msg, yylineno);
} }
......
...@@ -108,6 +108,15 @@ typedef enum { ...@@ -108,6 +108,15 @@ typedef enum {
} EShOptimizationLevel; } EShOptimizationLevel;
// //
// Message choices for what errors and warnings are given.
//
enum EShMessages {
EShMsgDefault = 0, // default is to give all required errors and extra warnings
EShMsgRelaxedErrors = (1 << 0), // be liberal in accepting input
EShMsgSuppressWarnings = (1 << 1) // suppress all warnings, except those required by the specification
};
//
// Build a table for bindings. This can be used for locating // Build a table for bindings. This can be used for locating
// attributes, uniforms, globals, etc., as needed. // attributes, uniforms, globals, etc., as needed.
// //
...@@ -155,9 +164,9 @@ SH_IMPORT_EXPORT int ShCompile( ...@@ -155,9 +164,9 @@ SH_IMPORT_EXPORT int ShCompile(
const EShOptimizationLevel, const EShOptimizationLevel,
const TBuiltInResource *resources, const TBuiltInResource *resources,
int debugOptions, int debugOptions,
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
bool forwardCompatible = false, // give errors for use of deprecated features bool forwardCompatible = false, // give errors for use of deprecated features
bool relaxedChecking = false // no warnings, reduced errors EShMessages messages = EShMsgDefault // warnings and errors
); );
......
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