From 8116cfc9bf1b48f61f85c8d059879b7ef2c34efb Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Sat, 9 Dec 2017 04:42:42 -0700
Subject: [PATCH] HLSL: Give error on unsupported buffer initializer.

---
 .../hlsl.localStructuredBuffer.comp.out       | 44 +++----------------
 hlsl/hlslGrammar.cpp                          |  2 +
 2 files changed, 9 insertions(+), 37 deletions(-)

diff --git a/Test/baseResults/hlsl.localStructuredBuffer.comp.out b/Test/baseResults/hlsl.localStructuredBuffer.comp.out
index 98257f4fe..8140f6d37 100644
--- a/Test/baseResults/hlsl.localStructuredBuffer.comp.out
+++ b/Test/baseResults/hlsl.localStructuredBuffer.comp.out
@@ -1,7 +1,11 @@
 hlsl.localStructuredBuffer.comp
+ERROR: 0:3: 'block initializer' : buffer aliasing not yet supported 
+ERROR: 1 compilation errors.  No code generated.
+
+
 Shader version: 500
 local_size = (1, 1, 1)
-0:? Sequence
+ERROR: node is still EOpNull!
 0:2  Function Definition: @main( ( temp void)
 0:2    Function Parameters: 
 0:2  Function Definition: main( ( temp void)
@@ -17,7 +21,7 @@ Linked compute stage:
 
 Shader version: 500
 local_size = (1, 1, 1)
-0:? Sequence
+ERROR: node is still EOpNull!
 0:2  Function Definition: @main( ( temp void)
 0:2    Function Parameters: 
 0:2  Function Definition: main( ( temp void)
@@ -27,38 +31,4 @@ local_size = (1, 1, 1)
 0:?   Linker Objects
 0:?     'srt0' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of uint @data})
 
-// Module Version 10000
-// Generated by (magic number): 80002
-// Id's are bound by 14
-
-                              Capability Shader
-               1:             ExtInstImport  "GLSL.std.450"
-                              MemoryModel Logical GLSL450
-                              EntryPoint GLCompute 4  "main"
-                              ExecutionMode 4 LocalSize 1 1 1
-                              Source HLSL 500
-                              Name 4  "main"
-                              Name 6  "@main("
-                              Name 11  "srt0"
-                              MemberName 11(srt0) 0  "@data"
-                              Name 13  "srt0"
-                              Decorate 10 ArrayStride 4
-                              MemberDecorate 11(srt0) 0 Offset 0
-                              Decorate 11(srt0) BufferBlock
-                              Decorate 13(srt0) DescriptorSet 0
-               2:             TypeVoid
-               3:             TypeFunction 2
-               9:             TypeInt 32 0
-              10:             TypeRuntimeArray 9(int)
-        11(srt0):             TypeStruct 10
-              12:             TypePointer Uniform 11(srt0)
-        13(srt0):     12(ptr) Variable Uniform
-         4(main):           2 Function None 3
-               5:             Label
-               8:           2 FunctionCall 6(@main()
-                              Return
-                              FunctionEnd
-       6(@main():           2 Function None 3
-               7:             Label
-                              Return
-                              FunctionEnd
+SPIR-V is not generated for failed compile or link
diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp
index 314a540b6..db7397cfd 100755
--- a/hlsl/hlslGrammar.cpp
+++ b/hlsl/hlslGrammar.cpp
@@ -478,6 +478,8 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
                 if (typedefDecl)
                     parseContext.declareTypedef(idToken.loc, *fullName, variableType);
                 else if (variableType.getBasicType() == EbtBlock) {
+                    if (expressionNode)
+                        parseContext.error(idToken.loc, "buffer aliasing not yet supported", "block initializer", "");
                     parseContext.declareBlock(idToken.loc, variableType, fullName,
                                               variableType.isArray() ? &variableType.getArraySizes() : nullptr);
                     parseContext.declareStructBufferCounter(idToken.loc, variableType, *fullName);
-- 
GitLab