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
This commit is contained in:
John Kessenich 2013-03-08 19:26:11 +00:00
Родитель 4055816bc9
Коммит 37827023c4
7 изменённых файлов: 26 добавлений и 17 удалений

Просмотреть файл

@ -259,7 +259,7 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons
for (int i = 0; i < 1000; ++i) {
for (int j = 0; j < 100; ++j)
#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
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));

Просмотреть файл

@ -40,11 +40,11 @@
#include <stdarg.h>
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),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
switchNestingLevel(0), inTypeParen(false),
version(v), profile(p), forwardCompatible(fc), relaxedChecking(rc),
version(v), profile(p), forwardCompatible(fc), messages(m),
contextPragma(true, false)
{
for (int type = 0; type < EbtNumTypes; ++type)

Просмотреть файл

@ -68,7 +68,7 @@ struct TPragma {
//
struct TParseContext {
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
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
TInfoSink& infoSink;
@ -86,7 +86,7 @@ struct TParseContext {
int version; // version, updated by #version in the shader
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 relaxedChecking; // suppress warnings and reduce error checking
EShMessages messages; // errors/warnings
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

Просмотреть файл

@ -484,7 +484,7 @@ int ShCompile(
int debugOptions,
int defaultVersion, // use 100 for ES environment, 110 for desktop
bool forwardCompatible, // give errors for use of deprecated features
bool relaxedChecking // no warnings, reduced errors
EShMessages messages // warnings/errors
)
{
if (!InitThread())
@ -522,7 +522,7 @@ int ShCompile(
// they get popped again further down.
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)
parseContext.error(1, "incorrect", "#version", "");

Просмотреть файл

@ -135,7 +135,7 @@ void TParseContext::checkDeprecated(int line, EProfile callingProfile, int depVe
if (forwardCompatible) {
error(line, "deprecated, may be removed in future release", featureDesc, "");
recover();
} else if (! relaxedChecking) {
} else if (! (messages & EShMsgSuppressWarnings)) {
infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " +
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
pyylval->lex.line = line;
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, "using future reserved keyword", yylineno);
}
@ -586,7 +586,7 @@ int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char*
pc.profile != EEsProfile && pc.version < version) {
pyylval->lex.line = yylineno;
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, "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
pyylval->lex.line = line;
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, "using ES precision qualifier keyword", yylineno);
}
@ -624,7 +624,7 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in
pyylval->lex.line = line;
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, "using future non-square matrix type keyword", yylineno);
}
@ -644,7 +644,7 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int
pyylval->lex.line = line;
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, "using future type keyword", yylineno);
}
@ -695,7 +695,7 @@ void CPPWarningToInfoLog(const char *msg)
{
TParseContext& pc = *((TParseContext *)cpp->pC);
if (! pc.relaxedChecking)
if (! (pc.messages & EShMsgSuppressWarnings))
pc.infoSink.info.message(EPrefixWarning, msg, yylineno);
}

Просмотреть файл

@ -107,6 +107,15 @@ typedef enum {
EShOptFull, // Optimizations that will take more time
} 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
// attributes, uniforms, globals, etc., as needed.
@ -155,9 +164,9 @@ SH_IMPORT_EXPORT int ShCompile(
const EShOptimizationLevel,
const TBuiltInResource *resources,
int debugOptions,
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
bool forwardCompatible = false, // give errors for use of deprecated features
bool relaxedChecking = false // no warnings, reduced errors
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
bool forwardCompatible = false, // give errors for use of deprecated features
EShMessages messages = EShMsgDefault // warnings and errors
);