From 437911af3313f2e2ff51cf520ee9fd9056f22ebf Mon Sep 17 00:00:00 2001
From: Aaron Muir Hamilton <aaron@correspondwith.me>
Date: Mon, 23 Oct 2017 15:31:10 +0000
Subject: [PATCH] GLSL: Check for implicit inner dimension in array of
 atomic_uint.

---
 .../implicitInnerAtomicUint.frag.out          | 21 +++++++++++++++++++
 Test/implicitInnerAtomicUint.frag             |  2 ++
 glslang/MachineIndependent/ParseHelper.cpp    |  2 +-
 gtests/AST.FromFile.cpp                       |  1 +
 4 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 Test/baseResults/implicitInnerAtomicUint.frag.out
 create mode 100644 Test/implicitInnerAtomicUint.frag

diff --git a/Test/baseResults/implicitInnerAtomicUint.frag.out b/Test/baseResults/implicitInnerAtomicUint.frag.out
new file mode 100644
index 000000000..6f68980c4
--- /dev/null
+++ b/Test/baseResults/implicitInnerAtomicUint.frag.out
@@ -0,0 +1,21 @@
+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/implicitInnerAtomicUint.frag b/Test/implicitInnerAtomicUint.frag
new file mode 100644
index 000000000..bb76516fd
--- /dev/null
+++ b/Test/implicitInnerAtomicUint.frag
@@ -0,0 +1,2 @@
+#version 460
+layout(binding = 0) uniform atomic_uint c[1][];
\ No newline at end of file
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 10c94d04a..a648b9bba 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -4863,7 +4863,7 @@ void TParseContext::fixOffset(const TSourceLoc& loc, TSymbol& symbol)
             // Check for overlap
             int numOffsets = 4;
             if (symbol.getType().isArray()) {
-                if (symbol.getType().isExplicitlySizedArray())
+                if (symbol.getType().isExplicitlySizedArray() && ! symbol.getType().getArraySizes()->isInnerImplicit())
                     numOffsets *= symbol.getType().getCumulativeArraySize();
                 else {
                     // "It is a compile-time error to declare an unsized array of atomic_uint."
diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp
index 9ca88ff8d..14545d1b5 100644
--- a/gtests/AST.FromFile.cpp
+++ b/gtests/AST.FromFile.cpp
@@ -159,6 +159,7 @@ INSTANTIATE_TEST_CASE_P(
         "460.vert",
         "dce.frag",
         "atomic_uint.frag",
+        "implicitInnerAtomicUint.frag",
         "aggOps.frag",
         "always-discard.frag",
         "always-discard2.frag",
-- 
GitLab