Add warning-suppression flag. Combined with relaxed errors, so an enum can be used...
authorJohn Kessenich <cepheus@frii.com>
Fri, 8 Mar 2013 19:26:11 +0000 (19:26 +0000)
committerJohn Kessenich <cepheus@frii.com>
Fri, 8 Mar 2013 19:26:11 +0000 (19:26 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20818 e7fa87d3-cd2b-0410-9028-fcbf551c1848

StandAlone/StandAlone.cpp
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.h
glslang/MachineIndependent/ShaderLang.cpp
glslang/MachineIndependent/Versions.cpp
glslang/MachineIndependent/glslang.l
glslang/Public/ShaderLang.h

index e397d36..4544664 100644 (file)
@@ -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));
index 0850a1f..001755f 100644 (file)
 #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)
index a9e7259..475a932 100644 (file)
@@ -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
 
index ef658bc..9a27d0e 100644 (file)
@@ -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", "");
index 16b651e..3aff363 100644 (file)
@@ -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);
             }
index 310f61e..48a7a96 100644 (file)
@@ -572,7 +572,7 @@ int PaIdentOrReserved(bool reserved, TParseContext& pc, int line, const char* te
 \r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
-    if (pc.futureCompatibility) {\r
+    if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {\r
         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
         pc.infoSink.info.message(EPrefixWarning, "using future reserved keyword", yylineno);\r
     }\r
@@ -586,7 +586,7 @@ int PaES30ReservedFromGLSL(int version, TParseContext& pc, int line, const char*
         pc.profile != EEsProfile && pc.version < version) {\r
             pyylval->lex.line = yylineno;\r
             pyylval->lex.string = NewPoolTString(yytext);\r
-            if (pc.futureCompatibility) {\r
+            if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {\r
                 pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
                 pc.infoSink.info.message(EPrefixWarning, "future reserved word in ES 300 and keyword in GLSL", yylineno);\r
             }\r
@@ -609,7 +609,7 @@ int PaPrecisionKeyword(TParseContext& pc, int line, const char* text, YYSTYPE* p
 \r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
-    if (pc.futureCompatibility) {\r
+    if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {\r
         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
         pc.infoSink.info.message(EPrefixWarning, "using ES precision qualifier keyword", yylineno);\r
     }\r
@@ -624,7 +624,7 @@ int PaMatNxM(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, in
 \r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
-    if (pc.futureCompatibility) {\r
+    if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {\r
         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
         pc.infoSink.info.message(EPrefixWarning, "using future non-square matrix type keyword", yylineno);\r
     }\r
@@ -644,7 +644,7 @@ int PaDMat(TParseContext& pc, int line, const char* text, YYSTYPE* pyylval, int
 \r
     pyylval->lex.line = line;\r
     pyylval->lex.string = NewPoolTString(text);\r
-    if (pc.futureCompatibility) {\r
+    if (pc.futureCompatibility && ! (pc.messages & EShMsgSuppressWarnings)) {\r
         pc.infoSink.info.message(EPrefixWarning, pyylval->lex.string->c_str(), yylineno);\r
         pc.infoSink.info.message(EPrefixWarning, "using future type keyword", yylineno);\r
     }\r
@@ -695,7 +695,7 @@ void CPPWarningToInfoLog(const char *msg)
 {\r
     TParseContext& pc = *((TParseContext *)cpp->pC);\r
 \r
-    if (! pc.relaxedChecking)\r
+    if (! (pc.messages & EShMsgSuppressWarnings))\r
         pc.infoSink.info.message(EPrefixWarning, msg, yylineno);\r
 }\r
 \r
index f60388d..01b204c 100644 (file)
@@ -108,6 +108,15 @@ typedef enum {
 } 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
     );