glslang: Fix over 100 warnings from MSVC warning level 4.
[platform/upstream/glslang.git] / glslang / MachineIndependent / Scan.cpp
index 1d7c417..6c56c1c 100644 (file)
@@ -249,7 +249,7 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile, bool& notFirstT
         for (profileLength = 0; profileLength < maxProfileLength; ++profileLength) {
             if (c < 0 || c == ' ' || c == '\t' || c == '\n' || c == '\r')
                 break;
-            profileString[profileLength] = c;
+            profileString[profileLength] = (char)c;
             c = get();
         }
         if (c > 0 && c != ' ' && c != '\t' && c != '\n' && c != '\r') {
@@ -274,6 +274,9 @@ public:
     explicit TParserToken(YYSTYPE& b) : sType(b) { }
 
     YYSTYPE& sType;
+protected:
+    TParserToken(TParserToken&);
+    TParserToken& operator=(TParserToken&);
 };
 
 } // end namespace glslang
@@ -514,6 +517,14 @@ void TScanContext::fillInKeywordMap()
     ReservedSet->insert("using");
 }
 
+void TScanContext::deleteKeywordMap()
+{
+    delete KeywordMap;
+    KeywordMap = 0;
+    delete ReservedSet;
+    ReservedSet = 0;
+}
+
 int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
 {
     do {
@@ -586,7 +597,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
                                    
         default:
             char buf[2];
-            buf[0] = ppToken.token;
+            buf[0] = (char)ppToken.token;
             buf[1] = 0;
             parseContext.error(loc, "unexpected token", buf, "");
             break;
@@ -677,8 +688,7 @@ int TScanContext::tokenizeIdentifier()
         if (parseContext.profile == EEsProfile && parseContext.version >= 310 ||
             parseContext.extensionsTurnedOn(1, &GL_ARB_shader_atomic_counters))
             return keyword;
-        else
-            return es30ReservedFromGLSL(420);
+        return es30ReservedFromGLSL(420);
 
     case COHERENT:
     case RESTRICT:
@@ -686,21 +696,26 @@ int TScanContext::tokenizeIdentifier()
     case WRITEONLY:
         if (parseContext.profile == EEsProfile && parseContext.version >= 310)
             return keyword;
-        else
-            return es30ReservedFromGLSL(parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store) ? 130 : 420);
+        return es30ReservedFromGLSL(parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store) ? 130 : 420);
 
     case VOLATILE:
+        if (parseContext.profile == EEsProfile && parseContext.version >= 310)
+            return keyword;
         if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionsTurnedOn(1, &GL_ARB_shader_image_load_store))))
             reservedWord();
         return keyword;
 
     case LAYOUT:
+    {
+        const int numLayoutExts = 2;
+        const char* layoutExts[numLayoutExts] = { GL_ARB_shading_language_420pack,
+                                                  GL_ARB_explicit_attrib_location };
         if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
             (parseContext.profile != EEsProfile && parseContext.version < 140 &&
-            ! parseContext.extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)))
+            ! parseContext.extensionsTurnedOn(numLayoutExts, layoutExts)))
             return identifierOrType();
         return keyword;
-
+    }
     case SHARED:
         if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
             (parseContext.profile != EEsProfile && parseContext.version < 140))