Increase MSVC warning level to 4.

There are some exceptions, a subset of the exceptions used by Chromium. They didn't seem to be useful warnings.

In code which we don't change much, like the preprocessor, I just suppressed the warnings in the specific files rather than changing the code.

There should be no functional changes in this patch.
Review URL: https://codereview.appspot.com/5570066

git-svn-id: https://angleproject.googlecode.com/svn/trunk@964 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/ConstantUnion.h b/src/compiler/ConstantUnion.h
index d28a11b..fd9d94d 100644
--- a/src/compiler/ConstantUnion.h
+++ b/src/compiler/ConstantUnion.h
@@ -11,6 +11,10 @@
 
 class ConstantUnion {
 public:
+    ConstantUnion()
+    {
+        iConst = 0;
+    }
 
     POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)        
     void setIConst(int i) {iConst = i; type = EbtInt; }
@@ -54,8 +58,6 @@
         default:
             return false;
         }
-
-        return false;
     }
 
     bool operator!=(const int i) const
@@ -89,8 +91,6 @@
         default:
             return false;   // Invalid operation, handled at semantic analysis
         }
-
-        return false;
     }
 
     bool operator<(const ConstantUnion& constant) const
@@ -104,8 +104,6 @@
         default:
             return false;   // Invalid operation, handled at semantic analysis
         }
-
-        return false;
     }
 
     ConstantUnion operator+(const ConstantUnion& constant) const
diff --git a/src/compiler/Intermediate.cpp b/src/compiler/Intermediate.cpp
index e1e8da2..ca6d8f7 100644
--- a/src/compiler/Intermediate.cpp
+++ b/src/compiler/Intermediate.cpp
@@ -1371,8 +1371,6 @@
         newNode->setLine(getLine());
         return newNode;
     }
-
-    return this;
 }
 
 TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermConstantUnion* node)
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index e10c81f..5400f8c 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -1032,8 +1032,6 @@
 
 bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
 {
-    TInfoSinkBase &out = mBody;
-
     switch (node->getOp())
     {
       case EOpNegative:         outputTriplet(visit, "(-", "", ")");  break;
@@ -1110,7 +1108,6 @@
 
 bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
 {
-    ShShaderType shaderType = mContext.shaderType;
     TInfoSinkBase &out = mBody;
 
     switch (node->getOp())
@@ -1839,7 +1836,6 @@
 
             while (iterations > 0)
             {
-                int remainder = (limit - initial) % increment;
                 int clampedLimit = initial + increment * std::min(255, iterations);
 
                 // for(int index = initial; index < clampedLimit; index += increment)
diff --git a/src/compiler/glslang.l b/src/compiler/glslang.l
index 3c88cc6..bade256 100644
--- a/src/compiler/glslang.l
+++ b/src/compiler/glslang.l
@@ -24,9 +24,13 @@
 
 // Ignore errors in auto-generated code.
 #if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 #elif defined(_MSC_VER)
 #pragma warning(disable: 4065)
+#pragma warning(disable: 4189)
+#pragma warning(disable: 4505)
+#pragma warning(disable: 4701)
 #endif
 }
 
diff --git a/src/compiler/glslang.y b/src/compiler/glslang.y
index bf3c124..b27d731 100644
--- a/src/compiler/glslang.y
+++ b/src/compiler/glslang.y
@@ -24,9 +24,13 @@
 
 // Ignore errors in auto-generated code.
 #if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 #elif defined(_MSC_VER)
 #pragma warning(disable: 4065)
+#pragma warning(disable: 4189)
+#pragma warning(disable: 4505)
+#pragma warning(disable: 4701)
 #endif
 
 #include "compiler/SymbolTable.h"
diff --git a/src/compiler/glslang_lex.cpp b/src/compiler/glslang_lex.cpp
index 655a7bb..75659f8 100644
--- a/src/compiler/glslang_lex.cpp
+++ b/src/compiler/glslang_lex.cpp
@@ -9,14 +9,18 @@
 
 // Ignore errors in auto-generated code.
 #if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 #elif defined(_MSC_VER)
 #pragma warning(disable: 4065)
+#pragma warning(disable: 4189)
+#pragma warning(disable: 4505)
+#pragma warning(disable: 4701)
 #endif
 
 
 
-#line 20 "./glslang_lex.cpp"
+#line 24 "./glslang_lex.cpp"
 
 #define  YY_INT_ALIGNED short int
 
diff --git a/src/compiler/glslang_tab.cpp b/src/compiler/glslang_tab.cpp
index cfce783..9847bd7 100644
--- a/src/compiler/glslang_tab.cpp
+++ b/src/compiler/glslang_tab.cpp
@@ -272,9 +272,13 @@
 
 // Ignore errors in auto-generated code.
 #if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 #elif defined(_MSC_VER)
 #pragma warning(disable: 4065)
+#pragma warning(disable: 4189)
+#pragma warning(disable: 4505)
+#pragma warning(disable: 4701)
 #endif
 
 #include "compiler/SymbolTable.h"
@@ -742,26 +746,26 @@
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   160,   160,   195,   198,   211,   216,   221,   227,   230,
-     303,   306,   415,   425,   438,   446,   545,   548,   556,   560,
-     567,   571,   578,   584,   593,   601,   656,   663,   673,   676,
-     686,   696,   717,   718,   719,   724,   725,   734,   746,   747,
-     755,   766,   770,   771,   781,   791,   801,   814,   815,   825,
-     838,   842,   846,   850,   851,   864,   865,   878,   879,   892,
-     893,   910,   911,   924,   925,   926,   927,   928,   932,   935,
-     946,   954,   979,   984,   991,  1027,  1030,  1037,  1045,  1066,
-    1085,  1096,  1125,  1130,  1140,  1145,  1155,  1158,  1161,  1164,
-    1170,  1177,  1180,  1196,  1214,  1238,  1261,  1265,  1283,  1291,
-    1323,  1343,  1419,  1428,  1451,  1454,  1460,  1468,  1476,  1484,
-    1494,  1501,  1504,  1507,  1513,  1516,  1531,  1535,  1539,  1543,
-    1552,  1557,  1562,  1567,  1572,  1577,  1582,  1587,  1592,  1597,
-    1603,  1609,  1615,  1620,  1625,  1634,  1643,  1648,  1661,  1661,
-    1675,  1675,  1684,  1687,  1702,  1738,  1742,  1748,  1756,  1772,
-    1776,  1780,  1781,  1787,  1788,  1789,  1790,  1791,  1795,  1796,
-    1796,  1796,  1806,  1807,  1812,  1815,  1825,  1828,  1834,  1835,
-    1839,  1847,  1851,  1861,  1866,  1883,  1883,  1888,  1888,  1895,
-    1895,  1903,  1906,  1912,  1915,  1921,  1925,  1932,  1939,  1946,
-    1953,  1964,  1973,  1977,  1984,  1987,  1993,  1993
+       0,   164,   164,   199,   202,   215,   220,   225,   231,   234,
+     307,   310,   419,   429,   442,   450,   549,   552,   560,   564,
+     571,   575,   582,   588,   597,   605,   660,   667,   677,   680,
+     690,   700,   721,   722,   723,   728,   729,   738,   750,   751,
+     759,   770,   774,   775,   785,   795,   805,   818,   819,   829,
+     842,   846,   850,   854,   855,   868,   869,   882,   883,   896,
+     897,   914,   915,   928,   929,   930,   931,   932,   936,   939,
+     950,   958,   983,   988,   995,  1031,  1034,  1041,  1049,  1070,
+    1089,  1100,  1129,  1134,  1144,  1149,  1159,  1162,  1165,  1168,
+    1174,  1181,  1184,  1200,  1218,  1242,  1265,  1269,  1287,  1295,
+    1327,  1347,  1423,  1432,  1455,  1458,  1464,  1472,  1480,  1488,
+    1498,  1505,  1508,  1511,  1517,  1520,  1535,  1539,  1543,  1547,
+    1556,  1561,  1566,  1571,  1576,  1581,  1586,  1591,  1596,  1601,
+    1607,  1613,  1619,  1624,  1629,  1638,  1647,  1652,  1665,  1665,
+    1679,  1679,  1688,  1691,  1706,  1742,  1746,  1752,  1760,  1776,
+    1780,  1784,  1785,  1791,  1792,  1793,  1794,  1795,  1799,  1800,
+    1800,  1800,  1810,  1811,  1816,  1819,  1829,  1832,  1838,  1839,
+    1843,  1851,  1855,  1865,  1870,  1887,  1887,  1892,  1892,  1899,
+    1899,  1907,  1910,  1916,  1919,  1925,  1929,  1936,  1943,  1950,
+    1957,  1968,  1977,  1981,  1988,  1991,  1997,  1997
 };
 #endif
 
diff --git a/src/compiler/preprocessor/cpp.c b/src/compiler/preprocessor/cpp.c
index 03dd4f6..13a5df1 100644
--- a/src/compiler/preprocessor/cpp.c
+++ b/src/compiler/preprocessor/cpp.c
@@ -53,6 +53,12 @@
 
 #include "compiler/preprocessor/slglobals.h"
 
+#if defined(_MSC_VER)
+#pragma warning(disable: 4054)
+#pragma warning(disable: 4152)
+#pragma warning(disable: 4706)
+#endif
+
 static int CPPif(yystypepp * yylvalpp);
 
 /* Don't use memory.c's replacements, as we clean up properly here */
diff --git a/src/compiler/preprocessor/memory.c b/src/compiler/preprocessor/memory.c
index e6fea7a..029521a 100644
--- a/src/compiler/preprocessor/memory.c
+++ b/src/compiler/preprocessor/memory.c
@@ -52,6 +52,10 @@
 
 #include "compiler/preprocessor/memory.h"
 
+#if defined(_MSC_VER)
+#pragma warning(disable: 4706)
+#endif
+
 // default alignment and chunksize, if called with 0 arguments
 #define CHUNKSIZE       (64*1024)
 #define ALIGN           8
diff --git a/src/compiler/preprocessor/scanner.c b/src/compiler/preprocessor/scanner.c
index deedb43..60b66bd 100644
--- a/src/compiler/preprocessor/scanner.c
+++ b/src/compiler/preprocessor/scanner.c
@@ -665,8 +665,6 @@
             return 0;
         }
     }
-
-    return 0;
 } // yylex
 
 //Checks if the token just read is EOF or not.
diff --git a/src/compiler/preprocessor/symbols.c b/src/compiler/preprocessor/symbols.c
index 5baedf5..f18b256 100644
--- a/src/compiler/preprocessor/symbols.c
+++ b/src/compiler/preprocessor/symbols.c
@@ -51,6 +51,10 @@
 
 #include "compiler/preprocessor/slglobals.h"
 
+#if defined(_MSC_VER)
+#pragma warning(disable: 4706)
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/compiler/preprocessor/tokens.c b/src/compiler/preprocessor/tokens.c
index aa83d2f..d658c12 100644
--- a/src/compiler/preprocessor/tokens.c
+++ b/src/compiler/preprocessor/tokens.c
@@ -54,6 +54,11 @@
 #include "compiler/preprocessor/slglobals.h"
 #include "compiler/util.h"
 
+#if defined(_MSC_VER)
+#pragma warning(disable: 4054)
+#pragma warning(disable: 4152)
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/compiler/translator_common.vcproj b/src/compiler/translator_common.vcproj
index 46056a1..c7e7faf 100644
--- a/src/compiler/translator_common.vcproj
+++ b/src/compiler/translator_common.vcproj
@@ -50,7 +50,8 @@
 				BasicRuntimeChecks="3"

 				RuntimeLibrary="1"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				Detect64BitPortabilityProblems="false"

 				DebugInformationFormat="4"

 				WarnAsError="true"

@@ -114,7 +115,8 @@
 				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0"

 				RuntimeLibrary="0"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				Detect64BitPortabilityProblems="false"

 				DebugInformationFormat="3"

 				WarnAsError="true"

@@ -179,7 +181,8 @@
 				BasicRuntimeChecks="3"

 				RuntimeLibrary="1"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				Detect64BitPortabilityProblems="false"

 				DebugInformationFormat="3"

 				WarnAsError="true"

@@ -244,7 +247,8 @@
 				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0"

 				RuntimeLibrary="0"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				Detect64BitPortabilityProblems="false"

 				DebugInformationFormat="3"

 				WarnAsError="true"

diff --git a/src/compiler/translator_hlsl.vcproj b/src/compiler/translator_hlsl.vcproj
index 5c59504..708a3bd 100644
--- a/src/compiler/translator_hlsl.vcproj
+++ b/src/compiler/translator_hlsl.vcproj
@@ -50,7 +50,8 @@
 				BasicRuntimeChecks="3"

 				RuntimeLibrary="1"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				DebugInformationFormat="4"

 				WarnAsError="true"

 			/>

@@ -115,7 +116,8 @@
 				RuntimeLibrary="0"

 				EnableFunctionLevelLinking="true"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				DebugInformationFormat="3"

 				WarnAsError="true"

 			/>

@@ -179,7 +181,8 @@
 				BasicRuntimeChecks="3"

 				RuntimeLibrary="1"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				DebugInformationFormat="3"

 				WarnAsError="true"

 			/>

@@ -245,7 +248,8 @@
 				RuntimeLibrary="0"

 				EnableFunctionLevelLinking="true"

 				UsePrecompiledHeader="0"

-				WarningLevel="3"

+				WarningLevel="4"

+				DisableSpecificWarnings="4100;4127;4189;4239;4244;4245;4389;4512;4702;4718"

 				DebugInformationFormat="3"

 				WarnAsError="true"

 			/>