SPV: For GLSL only, bitcast OpArrayLength result back to int.

This makes the rest of the AST consuming the result match GLSL
semantics and hence get complete type matching.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 5c00024..3d0d65e 100755
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -1825,6 +1825,12 @@
         unsigned int member = node->getOperand()->getAsBinaryNode()->getRight()->getAsConstantUnion()->getConstArray()[0].getUConst();
         spv::Id length = builder.createArrayLength(builder.accessChainGetLValue(), member);
 
+        // GLSL semantics say the result of .length() is an int, while SPIR-V says
+        // signedness must be 0. So, convert from SPIR-V unsigned back to GLSL's
+        // AST expectation of a signed result.
+        if (glslangIntermediate->getSource() == glslang::EShSourceGlsl)
+            length = builder.createUnaryOp(spv::OpBitcast, builder.makeIntType(32), length);
+
         builder.clearAccessChain();
         builder.setAccessChainRValue(length);
 
diff --git a/Test/baseResults/spv.310.comp.out b/Test/baseResults/spv.310.comp.out
index d5e3f51..f4eaa20 100644
--- a/Test/baseResults/spv.310.comp.out
+++ b/Test/baseResults/spv.310.comp.out
@@ -1,18 +1,14 @@
 spv.310.comp
-error: SPIRV-Tools Validation Errors
-error: OpStore Pointer <id> '62's type does not match Object <id> '60's type.
-  OpStore %62 %60
-
 // Module Version 10000
 // Generated by (magic number): 80007
-// Id's are bound by 71
+// Id's are bound by 72
 
                               Capability Shader
                               Capability DeviceGroup
                               Extension  "SPV_KHR_device_group"
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint GLCompute 4  "main" 53 64
+                              EntryPoint GLCompute 4  "main" 53 65
                               ExecutionMode 4 LocalSize 16 32 4
                               Source ESSL 310
                               SourceExtension  "GL_EXT_device_group"
@@ -34,7 +30,7 @@
                               MemberName 48(outs) 1  "va"
                               Name 50  "outnames"
                               Name 53  "gl_LocalInvocationID"
-                              Name 64  "gl_DeviceIndex"
+                              Name 65  "gl_DeviceIndex"
                               Decorate 11 ArrayStride 16
                               MemberDecorate 12(outb) 0 Offset 0
                               MemberDecorate 12(outb) 1 Offset 4
@@ -52,8 +48,8 @@
                               Decorate 48(outs) BufferBlock
                               Decorate 50(outnames) DescriptorSet 0
                               Decorate 53(gl_LocalInvocationID) BuiltIn LocalInvocationId
-                              Decorate 64(gl_DeviceIndex) BuiltIn DeviceIndex
-                              Decorate 70 BuiltIn WorkgroupSize
+                              Decorate 65(gl_DeviceIndex) BuiltIn DeviceIndex
+                              Decorate 71 BuiltIn WorkgroupSize
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeInt 32 0
@@ -93,15 +89,15 @@
               52:             TypePointer Input 51(ivec3)
 53(gl_LocalInvocationID):     52(ptr) Variable Input
               54:             TypePointer Input 6(int)
-              61:             TypePointer Uniform 15(int)
-              63:             TypePointer Input 15(int)
-64(gl_DeviceIndex):     63(ptr) Variable Input
-              65:      6(int) Constant 1
-              66:      6(int) Constant 3400
-              67:      6(int) Constant 16
-              68:      6(int) Constant 32
-              69:      6(int) Constant 4
-              70:   51(ivec3) ConstantComposite 67 68 69
+              62:             TypePointer Uniform 15(int)
+              64:             TypePointer Input 15(int)
+65(gl_DeviceIndex):     64(ptr) Variable Input
+              66:      6(int) Constant 1
+              67:      6(int) Constant 3400
+              68:      6(int) Constant 16
+              69:      6(int) Constant 32
+              70:      6(int) Constant 4
+              71:   51(ivec3) ConstantComposite 68 69 70
          4(main):           2 Function None 3
                5:             Label
                               ControlBarrier 7 7 8
@@ -129,9 +125,10 @@
               59:     29(ptr) AccessChain 50(outnames) 26 56
                               Store 59 58
               60:      6(int) ArrayLength 14(outbname) 3
-              62:     61(ptr) AccessChain 50(outnames) 16
-                              Store 62 60
-                              MemoryBarrier 65 8
-                              MemoryBarrier 7 66
+              61:     15(int) Bitcast 60
+              63:     62(ptr) AccessChain 50(outnames) 16
+                              Store 63 61
+                              MemoryBarrier 66 8
+                              MemoryBarrier 7 67
                               Return
                               FunctionEnd