Merge remote-tracking branch 'LocalGitHub/master'
diff --git a/Test/baseResults/constFoldIntMin.frag.out b/Test/baseResults/constFoldIntMin.frag.out
new file mode 100644
index 0000000..2c45ca8
--- /dev/null
+++ b/Test/baseResults/constFoldIntMin.frag.out
@@ -0,0 +1,51 @@
+constFoldIntMin.frag
+Shader version: 460
+Requested GL_AMD_gpu_shader_int16
+Requested GL_ARB_gpu_shader_int64
+0:? Sequence
+0:5  Function Definition: a( ( global void)
+0:5    Function Parameters: 
+0:6    Sequence
+0:6      Sequence
+0:6        move second child to first child ( temp int16_t)
+0:6          'u' ( temp int16_t)
+0:6          Constant:
+0:6            -32768 (const int16_t)
+0:7      Sequence
+0:7        move second child to first child ( temp int)
+0:7          'v' ( temp int)
+0:7          Constant:
+0:7            -2147483648 (const int)
+0:8      Sequence
+0:8        move second child to first child ( temp int64_t)
+0:8          'w' ( temp int64_t)
+0:8          Constant:
+0:8            -9223372036854775808 (const int64_t)
+0:9      Sequence
+0:9        move second child to first child ( temp int16_t)
+0:9          'x' ( temp int16_t)
+0:9          Constant:
+0:9            0 (const int8_t)
+0:10      Sequence
+0:10        move second child to first child ( temp int)
+0:10          'y' ( temp int)
+0:10          Constant:
+0:10            0 (const int)
+0:11      Sequence
+0:11        move second child to first child ( temp int64_t)
+0:11          'z' ( temp int64_t)
+0:11          Constant:
+0:11            0 (const int64_t)
+0:?   Linker Objects
+
+
+Linked fragment stage:
+
+ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
+
+Shader version: 460
+Requested GL_AMD_gpu_shader_int16
+Requested GL_ARB_gpu_shader_int64
+0:? Sequence
+0:?   Linker Objects
+
diff --git a/Test/baseResults/implicitInnerAtomicUint.frag.out b/Test/baseResults/implicitInnerAtomicUint.frag.out
deleted file mode 100644
index 6f68980..0000000
--- a/Test/baseResults/implicitInnerAtomicUint.frag.out
+++ /dev/null
@@ -1,21 +0,0 @@
-implicitInnerAtomicUint.frag
-ERROR: 0:2: '[]' : only outermost dimension of an array of arrays can be implicitly sized 
-ERROR: 0:2: 'atomic_uint' : array must be explicitly sized 
-ERROR: 2 compilation errors.  No code generated.
-
-
-Shader version: 460
-ERROR: node is still EOpNull!
-0:?   Linker Objects
-0:?     'c' (layout( binding=0 offset=0) uniform 1-element array of implicitly-sized array of atomic_uint)
-
-
-Linked fragment stage:
-
-ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
-
-Shader version: 460
-ERROR: node is still EOpNull!
-0:?   Linker Objects
-0:?     'c' (layout( binding=0 offset=0) uniform 1-element array of implicitly-sized array of atomic_uint)
-
diff --git a/Test/constFoldIntMin.frag b/Test/constFoldIntMin.frag
new file mode 100644
index 0000000..6861832
--- /dev/null
+++ b/Test/constFoldIntMin.frag
@@ -0,0 +1,12 @@
+#version 460 core
+#extension GL_AMD_gpu_shader_int16 : enable
+#extension GL_ARB_gpu_shader_int64 : enable
+
+void a(){
+    int16_t u = -32768S / -1S; // SHRT_MIN
+    int v = -2147483648 / -1; // INT_MIN
+    int64_t w = -9223372036854775808L / -1L; // LLONG_MIN
+    int16_t x = -32768S % -1S; // SHRT_MIN
+    int y = -2147483648 % -1; // INT_MIN
+    int64_t z = -9223372036854775808L % -1L; // LLONG_MIN
+}
\ No newline at end of file
diff --git a/Test/implicitInnerAtomicUint.frag b/Test/implicitInnerAtomicUint.frag
deleted file mode 100644
index bb76516..0000000
--- a/Test/implicitInnerAtomicUint.frag
+++ /dev/null
@@ -1,2 +0,0 @@
-#version 460
-layout(binding = 0) uniform atomic_uint c[1][];
\ No newline at end of file
diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp
index 313c54f..142492d 100644
--- a/glslang/MachineIndependent/Constant.cpp
+++ b/glslang/MachineIndependent/Constant.cpp
@@ -39,6 +39,7 @@
 #include <cmath>
 #include <cfloat>
 #include <cstdlib>
+#include <climits>
 
 namespace {
 
@@ -276,8 +277,31 @@
         for (int i = 0; i < newComps; i++) {
             if (rightUnionArray[i] == 0)
                 newConstArray[i] = leftUnionArray[i];
-            else
-                newConstArray[i] = leftUnionArray[i] % rightUnionArray[i];
+            else {
+                switch (getType().getBasicType()) {
+                case EbtInt:
+                    if (rightUnionArray[i].getIConst() == -1 && leftUnionArray[i].getIConst() == INT_MIN) {
+                        newConstArray[i].setIConst(0);
+                        break;
+                    } else goto modulo_default;
+
+                case EbtInt64:
+                    if (rightUnionArray[i].getI64Const() == -1 && leftUnionArray[i].getI64Const() == LLONG_MIN) {
+                        newConstArray[i].setI64Const(0);
+                        break;
+                    } else goto modulo_default;
+#ifdef AMD_EXTENSIONS
+                case EbtInt16:
+                    if (rightUnionArray[i].getIConst() == -1 && leftUnionArray[i].getIConst() == SHRT_MIN) {
+                        newConstArray[i].setIConst(0);
+                        break;
+                    } else goto modulo_default;
+#endif
+                default:
+                modulo_default:
+                    newConstArray[i] = leftUnionArray[i] % rightUnionArray[i];
+                }
+            }
         }
         break;
 
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index bad9244..0143b4d 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -1,7 +1,7 @@
 //
 // Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
 // Copyright (C) 2012-2016 LunarG, Inc.
-// Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2015-2017 Google, Inc.
 // Copyright (C) 2017 ARM Limited.
 //
 // All rights reserved.
diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp
index b978fda..63ffd1d 100644
--- a/gtests/AST.FromFile.cpp
+++ b/gtests/AST.FromFile.cpp
@@ -115,6 +115,7 @@
         "330comp.frag",
         "constErrors.frag",
         "constFold.frag",
+        "constFoldIntMin.frag",
         "errors.frag",
         "forwardRef.frag",
         "uint.frag",
@@ -159,7 +160,7 @@
         "460.vert",
         "dce.frag",
         "atomic_uint.frag",
-        "implicitInnerAtomicUint.frag",
+//        "implicitInnerAtomicUint.frag",
         "aggOps.frag",
         "always-discard.frag",
         "always-discard2.frag",
diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp
index c9d858c..df444f5 100755
--- a/hlsl/hlslParseHelper.cpp
+++ b/hlsl/hlslParseHelper.cpp
@@ -1,6 +1,6 @@
 //
-// Copyright (C) 2016 Google, Inc.
-// Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2017 Google, Inc.
+// Copyright (C) 2017 LunarG, Inc.
 //
 // All rights reserved.
 //
diff --git a/update_glslang_sources.py b/update_glslang_sources.py
index b2988f9..331a301 100755
--- a/update_glslang_sources.py
+++ b/update_glslang_sources.py
@@ -141,7 +141,7 @@
 
     # Create the subdirectories in sorted order so that parent git repositories
     # are created first.
-    for c in sorted(commits, cmp=lambda x,y: cmp(x.subdir, y.subdir)):
+    for c in sorted(commits, key=lambda x: x.subdir):
         print('Get {n}\n'.format(n=c.name))
         c.Checkout()
     sys.exit(0)