From 69d01eadd6e8225ca2f42604ece1b43d5555d298 Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Tue, 22 Dec 2015 16:39:07 -0700
Subject: [PATCH] Semantics: Catch nested types containing 'int' with
 non-'flat' interpolation.

---
 Test/300.frag                              | 2 +-
 Test/baseResults/300.frag.out              | 3 ++-
 glslang/Include/revision.h                 | 4 ++--
 glslang/MachineIndependent/ParseHelper.cpp | 9 +++++++--
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/Test/300.frag b/Test/300.frag
index 97f31015f..ca2e2cb3e 100644
--- a/Test/300.frag
+++ b/Test/300.frag
@@ -37,7 +37,7 @@ struct s {
 };
 
 in s badout;               // ERROR, can't contain a sampler
-
+                           // ERROR, can't have int in struct without flat
 struct S2 {
     vec3 c;
     float f;
diff --git a/Test/baseResults/300.frag.out b/Test/baseResults/300.frag.out
index 6cc2103c8..eb752b4da 100644
--- a/Test/baseResults/300.frag.out
+++ b/Test/baseResults/300.frag.out
@@ -4,6 +4,7 @@ ERROR: 0:30: 'noperspective' : Reserved word.
 ERROR: 0:30: 'noperspective' : not supported with this profile: es
 ERROR: 0:31: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: bads
 ERROR: 0:32: 'uint' : cannot apply precision statement to this type; use 'float', 'int' or a sampler type 
+ERROR: 0:39: 'structure' : must be qualified as flat in
 ERROR: 0:39: 'structure' : non-uniform struct contains a sampler or image: badout
 ERROR: 0:60: 'texel offset' : argument must be compile-time constant 
 ERROR: 0:62: 'texel offset' : argument must be compile-time constant 
@@ -43,7 +44,7 @@ ERROR: 0:157: 'invariant' : can only apply to an output
 ERROR: 0:158: 'invariant' : can only apply to an output 
 ERROR: 0:160: 'imageBuffer' : Reserved word. 
 ERROR: 0:160: '' :  syntax error
-ERROR: 44 compilation errors.  No code generated.
+ERROR: 45 compilation errors.  No code generated.
 
 
 Shader version: 300
diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index a0d1fe057..582685c33 100644
--- a/glslang/Include/revision.h
+++ b/glslang/Include/revision.h
@@ -2,5 +2,5 @@
 // For the version, it uses the latest git tag followed by the number of commits.
 // For the date, it uses the current date (when then script is run).
 
-#define GLSLANG_REVISION "SPIRV99.864"
-#define GLSLANG_DATE "21-Dec-2015"
+#define GLSLANG_REVISION "SPIRV99.865"
+#define GLSLANG_DATE "22-Dec-2015"
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 9ed4f86ac..5836926ad 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -2415,9 +2415,14 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
         return;
     }
 
-    if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble) {
+    if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble)
         profileRequires(loc, EEsProfile, 300, nullptr, "shader input/output");
-        if (! qualifier.flat) {
+
+    if (! qualifier.flat) {
+        if (publicType.basicType == EbtInt || publicType.basicType == EbtUint || publicType.basicType == EbtDouble ||
+            (publicType.userDef && (publicType.userDef->containsBasicType(EbtInt) ||
+                                    publicType.userDef->containsBasicType(EbtUint) || 
+                                    publicType.userDef->containsBasicType(EbtDouble)))) {
             if (qualifier.storage == EvqVaryingIn && language == EShLangFragment)
                 error(loc, "must be qualified as flat", TType::getBasicString(publicType.basicType), GetStorageQualifierString(qualifier.storage));
             else if (qualifier.storage == EvqVaryingOut && language == EShLangVertex && version == 300)
-- 
GitLab