瀏覽代碼

Fix const error check for object subscript operator (#3580)

(cherry picked from commit de00b014ac3554bea9c8d3b440c8fae7b531f42c)
Tex Riddell 4 年之前
父節點
當前提交
6590576a1f

+ 4 - 1
tools/clang/lib/Sema/SemaExpr.cpp

@@ -9460,7 +9460,10 @@ bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) { // HLSL Ch
   assert(!E->hasPlaceholderType(BuiltinType::PseudoObject));
   assert(!E->hasPlaceholderType(BuiltinType::PseudoObject));
   // HLSL Change Starts - check const for array subscript operator for HLSL vector/matrix
   // HLSL Change Starts - check const for array subscript operator for HLSL vector/matrix
   if (S.Context.getLangOpts().HLSL && E->getStmtClass() == Stmt::CXXOperatorCallExprClass) {
   if (S.Context.getLangOpts().HLSL && E->getStmtClass() == Stmt::CXXOperatorCallExprClass) {
-      // check if it's a vector or matrix
+    // check if it's a vector or matrix
+    const CXXOperatorCallExpr *expr = cast<CXXOperatorCallExpr>(E);
+    QualType qt = expr->getArg(0)->getType();
+    if ((hlsl::IsMatrixType(&S, qt) || hlsl::IsVectorType(&S, qt)))
       return HLSLCheckForModifiableLValue(E, Loc, S);
       return HLSLCheckForModifiableLValue(E, Loc, S);
   }
   }
   // HLSL Change Ends
   // HLSL Change Ends

+ 2 - 2
tools/clang/test/HLSL/array-index-out-of-bounds-HV-2016.hlsl

@@ -3,10 +3,10 @@
 void dead()
 void dead()
 {
 {
     int array[2];
     int array[2];
-    array[-1] = 0;                                          /* expected-warning {{array index -1 is before the beginning of the array}} fxc-pass */
+    array[-1] = 0;                                          /* expected-warning {{array index -1 is before the beginning of the array}} fxc-pass {{}} */
     array[0] = 0;
     array[0] = 0;
     array[1] = 0;
     array[1] = 0;
-    array[2] = 0;                                           /* expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} fxc-pass */
+    array[2] = 0;                                           /* expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} fxc-pass {{}} */
 }
 }
 
 
 void main() {}
 void main() {}

+ 52 - 52
tools/clang/test/HLSL/attributes.hlsl

@@ -20,13 +20,13 @@ int loop_before_return() {
 }
 }
 
 
 int loop_before_if(int a) {
 int loop_before_if(int a) {
-  [loop] // expected-warning {{attribute 'loop' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [loop] // expected-warning {{attribute 'loop' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   if (a > 0) return -a;
   if (a > 0) return -a;
   return a;
   return a;
 }
 }
 
 
 int loop_before_switch(int a) {
 int loop_before_switch(int a) {
-  [loop] // expected-warning {{attribute 'loop' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [loop] // expected-warning {{attribute 'loop' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   switch (a) {
   switch (a) {
     case 0:
     case 0:
       return 1;
       return 1;
@@ -36,13 +36,13 @@ int loop_before_switch(int a) {
 }
 }
 
 
 int fastopt_before_if(int a) {
 int fastopt_before_if(int a) {
-  [fastopt] // expected-warning {{attribute 'fastopt' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [fastopt] // expected-warning {{attribute 'fastopt' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   if (a > 0) return -a;
   if (a > 0) return -a;
   return a;
   return a;
 }
 }
 
 
 int fastopt_before_switch(int a) {
 int fastopt_before_switch(int a) {
-  [fastopt] // expected-warning {{attribute 'fastopt' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [fastopt] // expected-warning {{attribute 'fastopt' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   switch (a) {
   switch (a) {
     case 0:
     case 0:
       return 1;
       return 1;
@@ -52,13 +52,13 @@ int fastopt_before_switch(int a) {
 }
 }
 
 
 int unroll_before_if(int a) {
 int unroll_before_if(int a) {
-  [unroll] // expected-warning {{attribute 'unroll' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [unroll] // expected-warning {{attribute 'unroll' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   if (a > 0) return -a;
   if (a > 0) return -a;
   return a;
   return a;
 }
 }
 
 
 int unroll_before_switch(int a) {
 int unroll_before_switch(int a) {
-  [unroll] // expected-warning {{attribute 'unroll' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [unroll] // expected-warning {{attribute 'unroll' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   switch (a) {
   switch (a) {
     case 0:
     case 0:
       return 1;
       return 1;
@@ -68,13 +68,13 @@ int unroll_before_switch(int a) {
 }
 }
 
 
 int allow_uav_condition_before_if(int a) {
 int allow_uav_condition_before_if(int a) {
-  [allow_uav_condition] // expected-warning {{attribute 'allow_uav_condition' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [allow_uav_condition] // expected-warning {{attribute 'allow_uav_condition' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   if (a > 0) return -a;
   if (a > 0) return -a;
   return a;
   return a;
 }
 }
 
 
 int allow_uav_condition_before_switch(int a) {
 int allow_uav_condition_before_switch(int a) {
-  [allow_uav_condition] // expected-warning {{attribute 'allow_uav_condition' can only be applied to 'for', 'while' and 'do' loop statements}}
+  [allow_uav_condition] // expected-warning {{attribute 'allow_uav_condition' can only be applied to 'for', 'while' and 'do' loop statements}} fxc-pass {{}}
   switch (a) {
   switch (a) {
     case 0:
     case 0:
       return 1;
       return 1;
@@ -85,7 +85,7 @@ int allow_uav_condition_before_switch(int a) {
 
 
 int branch_before_for() {
 int branch_before_for() {
   int result = 0;
   int result = 0;
-  [branch] // expected-warning {{attribute 'branch' can only be applied to 'if' and 'switch' statements}}
+  [branch] // expected-warning {{attribute 'branch' can only be applied to 'if' and 'switch' statements}} fxc-pass {{}}
   for (int i = 0; i < 10; i++) result++;
   for (int i = 0; i < 10; i++) result++;
   return result;
   return result;
 }
 }
@@ -93,7 +93,7 @@ int branch_before_for() {
 int branch_before_while() {
 int branch_before_while() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [branch] // expected-warning {{attribute 'branch' can only be applied to 'if' and 'switch' statements}}
+  [branch] // expected-warning {{attribute 'branch' can only be applied to 'if' and 'switch' statements}} fxc-pass {{}}
   while(i < 10) {
   while(i < 10) {
     result++;
     result++;
     i++;
     i++;
@@ -104,7 +104,7 @@ int branch_before_while() {
 int branch_before_do() {
 int branch_before_do() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [branch] // expected-warning {{attribute 'branch' can only be applied to 'if' and 'switch' statements}}
+  [branch] // expected-warning {{attribute 'branch' can only be applied to 'if' and 'switch' statements}} fxc-pass {{}}
   do {
   do {
     result++;
     result++;
     i++;
     i++;
@@ -114,7 +114,7 @@ int branch_before_do() {
 
 
 int flatten_before_for() {
 int flatten_before_for() {
   int result = 0;
   int result = 0;
-  [flatten] // expected-warning {{attribute 'flatten' can only be applied to 'if' and 'switch' statements}}
+  [flatten] // expected-warning {{attribute 'flatten' can only be applied to 'if' and 'switch' statements}} fxc-pass {{}}
   for (int i = 0; i < 10; i++) result++;
   for (int i = 0; i < 10; i++) result++;
   return result;
   return result;
 }
 }
@@ -122,7 +122,7 @@ int flatten_before_for() {
 int flatten_before_while() {
 int flatten_before_while() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [flatten] // expected-warning {{attribute 'flatten' can only be applied to 'if' and 'switch' statements}}
+  [flatten] // expected-warning {{attribute 'flatten' can only be applied to 'if' and 'switch' statements}} fxc-pass {{}}
   while(i < 10) {
   while(i < 10) {
     result++;
     result++;
     i++;
     i++;
@@ -133,7 +133,7 @@ int flatten_before_while() {
 int flatten_before_do() {
 int flatten_before_do() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [flatten] // expected-warning {{attribute 'flatten' can only be applied to 'if' and 'switch' statements}}
+  [flatten] // expected-warning {{attribute 'flatten' can only be applied to 'if' and 'switch' statements}} fxc-pass {{}}
   do {
   do {
     result++;
     result++;
     i++;
     i++;
@@ -143,7 +143,7 @@ int flatten_before_do() {
 
 
 int forcecase_before_for() {
 int forcecase_before_for() {
   int result = 0;
   int result = 0;
-  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}}
+  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}} fxc-pass {{}}
   for (int i = 0; i < 10; i++) result++;
   for (int i = 0; i < 10; i++) result++;
   return result;
   return result;
 }
 }
@@ -151,7 +151,7 @@ int forcecase_before_for() {
 int forcecase_before_while() {
 int forcecase_before_while() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}}
+  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}} fxc-pass {{}}
   while(i < 10) {
   while(i < 10) {
     result++;
     result++;
     i++;
     i++;
@@ -162,7 +162,7 @@ int forcecase_before_while() {
 int forcecase_before_do() {
 int forcecase_before_do() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}}
+  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}} fxc-pass {{}}
   do {
   do {
     result++;
     result++;
     i++;
     i++;
@@ -171,14 +171,14 @@ int forcecase_before_do() {
 }
 }
 
 
 int forcecase_before_if(int a) {
 int forcecase_before_if(int a) {
-  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}}
+  [forcecase] // expected-warning {{attribute 'forcecase' can only be applied to 'switch' statements}} fxc-pass {{}}
   if (a > 0) return -a;
   if (a > 0) return -a;
   return a;
   return a;
 }
 }
 
 
 int call_before_for() {
 int call_before_for() {
   int result = 0;
   int result = 0;
-  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}}
+  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}} fxc-pass {{}}
   for (int i = 0; i < 10; i++) result++;
   for (int i = 0; i < 10; i++) result++;
   return result;
   return result;
 }
 }
@@ -186,7 +186,7 @@ int call_before_for() {
 int call_before_while() {
 int call_before_while() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}}
+  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}} fxc-pass {{}}
   while(i < 10) {
   while(i < 10) {
     result++;
     result++;
     i++;
     i++;
@@ -197,7 +197,7 @@ int call_before_while() {
 int call_before_do() {
 int call_before_do() {
   int result = 0;
   int result = 0;
   int i = 0;
   int i = 0;
-  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}}
+  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}} fxc-pass {{}}
   do {
   do {
     result++;
     result++;
     i++;
     i++;
@@ -206,7 +206,7 @@ int call_before_do() {
 }
 }
 
 
 int call_before_if(int a) {
 int call_before_if(int a) {
-  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}}
+  [call] // expected-warning {{attribute 'call' can only be applied to 'switch' statements}} fxc-pass {{}}
   if (a > 0) return -a;
   if (a > 0) return -a;
   return a;
   return a;
 }
 }
@@ -256,9 +256,9 @@ int neg_unroll() {
   // fxc error X3084: cannot match attribute unroll, non-uint parameters found
   // fxc error X3084: cannot match attribute unroll, non-uint parameters found
   [unroll(-1)] // expected-warning {{attribute 'unroll' must have a uint literal argument}} fxc-error {{X3084: cannot match attribute unroll, non-uint parameters found}}
   [unroll(-1)] // expected-warning {{attribute 'unroll' must have a uint literal argument}} fxc-error {{X3084: cannot match attribute unroll, non-uint parameters found}}
   /*verify-ast
   /*verify-ast
-    AttributedStmt <col:3, line:85:39>
+    AttributedStmt <col:3, line:277:39>
     |-HLSLUnrollAttr <col:4, col:13> -1
     |-HLSLUnrollAttr <col:4, col:13> -1
-    `-ForStmt <line:85:3, col:39>
+    `-ForStmt <line:277:3, col:39>
       |-DeclStmt <col:8, col:17>
       |-DeclStmt <col:8, col:17>
       | `-VarDecl <col:8, col:16> col:12 used i 'int' cinit
       | `-VarDecl <col:8, col:16> col:12 used i 'int' cinit
       |   `-ImplicitCastExpr <col:16> 'int' <IntegralCast>
       |   `-ImplicitCastExpr <col:16> 'int' <IntegralCast>
@@ -286,9 +286,9 @@ int flt_unroll() {
   // fxc warning X3554: unknown attribute unroll, or attribute invalid for this statement, valid attributes are: loop, fastopt, unroll, allow_uav_condition
   // fxc warning X3554: unknown attribute unroll, or attribute invalid for this statement, valid attributes are: loop, fastopt, unroll, allow_uav_condition
   [unroll(1.5)] // expected-warning {{attribute 'unroll' must have a uint literal argument}} fxc-warning {{X3554: cannot match attribute unroll, parameter 1 is expected to be of type int}} fxc-warning {{X3554: unknown attribute unroll, or attribute invalid for this statement, valid attributes are: loop, fastopt, unroll, allow_uav_condition}}
   [unroll(1.5)] // expected-warning {{attribute 'unroll' must have a uint literal argument}} fxc-warning {{X3554: cannot match attribute unroll, parameter 1 is expected to be of type int}} fxc-warning {{X3554: unknown attribute unroll, or attribute invalid for this statement, valid attributes are: loop, fastopt, unroll, allow_uav_condition}}
   /*verify-ast
   /*verify-ast
-    AttributedStmt <col:3, line:115:39>
+    AttributedStmt <col:3, line:307:39>
     |-HLSLUnrollAttr <col:4, col:14> 0
     |-HLSLUnrollAttr <col:4, col:14> 0
-    `-ForStmt <line:115:3, col:39>
+    `-ForStmt <line:307:3, col:39>
       |-DeclStmt <col:8, col:17>
       |-DeclStmt <col:8, col:17>
       | `-VarDecl <col:8, col:16> col:12 used i 'int' cinit
       | `-VarDecl <col:8, col:16> col:12 used i 'int' cinit
       |   `-ImplicitCastExpr <col:16> 'int' <IntegralCast>
       |   `-ImplicitCastExpr <col:16> 'int' <IntegralCast>
@@ -327,9 +327,9 @@ int uav() {
   uint i;
   uint i;
   [allow_uav_condition]
   [allow_uav_condition]
   /*verify-ast
   /*verify-ast
-    AttributedStmt <col:3, line:156:3>
+    AttributedStmt <col:3, line:348:3>
     |-HLSLAllowUAVConditionAttr <col:4>
     |-HLSLAllowUAVConditionAttr <col:4>
-    `-ForStmt <line:155:3, line:156:3>
+    `-ForStmt <line:347:3, line:348:3>
       |-BinaryOperator <col:8, col:12> 'uint':'unsigned int' '='
       |-BinaryOperator <col:8, col:12> 'uint':'unsigned int' '='
       | |-DeclRefExpr <col:8> 'uint':'unsigned int' lvalue Var 'i' 'uint':'unsigned int'
       | |-DeclRefExpr <col:8> 'uint':'unsigned int' lvalue Var 'i' 'uint':'unsigned int'
       | `-ImplicitCastExpr <col:12> 'uint':'unsigned int' <LValueToRValue>
       | `-ImplicitCastExpr <col:12> 'uint':'unsigned int' <LValueToRValue>
@@ -342,7 +342,7 @@ int uav() {
       |   `-DeclRefExpr <col:38> 'const uint':'const unsigned int' lvalue Var 'g_dealiasTableSize' 'const uint':'const unsigned int'
       |   `-DeclRefExpr <col:38> 'const uint':'const unsigned int' lvalue Var 'g_dealiasTableSize' 'const uint':'const unsigned int'
       |-UnaryOperator <col:58, col:60> 'uint':'unsigned int' lvalue prefix '++'
       |-UnaryOperator <col:58, col:60> 'uint':'unsigned int' lvalue prefix '++'
       | `-DeclRefExpr <col:60> 'uint':'unsigned int' lvalue Var 'i' 'uint':'unsigned int'
       | `-DeclRefExpr <col:60> 'uint':'unsigned int' lvalue Var 'i' 'uint':'unsigned int'
-      `-CompoundStmt <col:63, line:156:3>
+      `-CompoundStmt <col:63, line:348:3>
   */
   */
   for (i = g_dealiasTableOffset; i < g_dealiasTableSize; ++i) {
   for (i = g_dealiasTableOffset; i < g_dealiasTableSize; ++i) {
   }
   }
@@ -393,16 +393,16 @@ void all_wrong() { }
 [patchconstantfunc("PatchFoo")]
 [patchconstantfunc("PatchFoo")]
 HSFoo HSMain( InputPatch<HSFoo, 16> p,
 HSFoo HSMain( InputPatch<HSFoo, 16> p,
 /*verify-ast
 /*verify-ast
-  FunctionDecl <col:1, line:276:1> line:202:7 HSMain 'HSFoo (InputPatch<HSFoo, 16>, uint, uint)'
+  FunctionDecl <col:1, line:468:1> line:394:7 HSMain 'HSFoo (InputPatch<HSFoo, 16>, uint, uint)'
   |-ParmVarDecl <col:15, col:37> col:37 used p 'InputPatch<HSFoo, 16>':'InputPatch<HSFoo, 16>'
   |-ParmVarDecl <col:15, col:37> col:37 used p 'InputPatch<HSFoo, 16>':'InputPatch<HSFoo, 16>'
-  |-ParmVarDecl <line:268:15, col:20> col:20 used i 'uint':'unsigned int'
+  |-ParmVarDecl <line:460:15, col:20> col:20 used i 'uint':'unsigned int'
   | `-SemanticDecl <col:24> "SV_OutputControlPointID"
   | `-SemanticDecl <col:24> "SV_OutputControlPointID"
-  |-ParmVarDecl <line:269:15, col:20> col:20 used PatchID 'uint':'unsigned int'
+  |-ParmVarDecl <line:461:15, col:20> col:20 used PatchID 'uint':'unsigned int'
   | `-SemanticDecl <col:30> "SV_PrimitiveID"
   | `-SemanticDecl <col:30> "SV_PrimitiveID"
-  |-CompoundStmt <line:270:1, line:276:1>
-  | |-DeclStmt <line:271:5, col:17>
+  |-CompoundStmt <line:462:1, line:468:1>
+  | |-DeclStmt <line:463:5, col:17>
   | | `-VarDecl <col:5, col:11> col:11 used output 'HSFoo' nrvo
   | | `-VarDecl <col:5, col:11> col:11 used output 'HSFoo' nrvo
-  | |-DeclStmt <line:272:5, col:41>
+  | |-DeclStmt <line:464:5, col:41>
   | | `-VarDecl <col:5, col:40> col:12 used r 'float4':'vector<float, 4>' cinit
   | | `-VarDecl <col:5, col:40> col:12 used r 'float4':'vector<float, 4>' cinit
   | |   `-CXXFunctionalCastExpr <col:16, col:40> 'float4':'vector<float, 4>' functional cast to float4 <NoOp>
   | |   `-CXXFunctionalCastExpr <col:16, col:40> 'float4':'vector<float, 4>' functional cast to float4 <NoOp>
   | |     `-InitListExpr <col:23, col:39> 'float4':'vector<float, 4>'
   | |     `-InitListExpr <col:23, col:39> 'float4':'vector<float, 4>'
@@ -417,7 +417,7 @@ HSFoo HSMain( InputPatch<HSFoo, 16> p,
   | |       |       `-DeclRefExpr <col:25> 'uint':'unsigned int' lvalue ParmVar 'PatchID' 'uint':'unsigned int'
   | |       |       `-DeclRefExpr <col:25> 'uint':'unsigned int' lvalue ParmVar 'PatchID' 'uint':'unsigned int'
   | |       `-ImplicitCastExpr <col:39> 'float' <IntegralToFloating>
   | |       `-ImplicitCastExpr <col:39> 'float' <IntegralToFloating>
   | |         `-IntegerLiteral <col:39> 'literal int' 1
   | |         `-IntegerLiteral <col:39> 'literal int' 1
-  | |-CompoundAssignOperator <line:273:5, col:30> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
+  | |-CompoundAssignOperator <line:465:5, col:30> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
   | | |-DeclRefExpr <col:5> 'float4':'vector<float, 4>' lvalue Var 'r' 'float4':'vector<float, 4>'
   | | |-DeclRefExpr <col:5> 'float4':'vector<float, 4>' lvalue Var 'r' 'float4':'vector<float, 4>'
   | | `-CXXMemberCallExpr <col:10, col:30> 'vector<float, 4>'
   | | `-CXXMemberCallExpr <col:10, col:30> 'vector<float, 4>'
   | |   |-MemberExpr <col:10, col:20> '<bound member function type>' .Load
   | |   |-MemberExpr <col:10, col:20> '<bound member function type>' .Load
@@ -432,7 +432,7 @@ HSFoo HSMain( InputPatch<HSFoo, 16> p,
   | |     `-ImplicitCastExpr <col:25, col:27> 'vector<float, 3>':'vector<float, 3>' <LValueToRValue>
   | |     `-ImplicitCastExpr <col:25, col:27> 'vector<float, 3>':'vector<float, 3>' <LValueToRValue>
   | |       `-HLSLVectorElementExpr <col:25, col:27> 'vector<float, 3>':'vector<float, 3>' lvalue vectorcomponent xyz
   | |       `-HLSLVectorElementExpr <col:25, col:27> 'vector<float, 3>':'vector<float, 3>' lvalue vectorcomponent xyz
   | |         `-DeclRefExpr <col:25> 'float4':'vector<float, 4>' lvalue Var 'r' 'float4':'vector<float, 4>'
   | |         `-DeclRefExpr <col:25> 'float4':'vector<float, 4>' lvalue Var 'r' 'float4':'vector<float, 4>'
-  | |-BinaryOperator <line:274:5, col:31> 'float3':'vector<float, 3>' '='
+  | |-BinaryOperator <line:466:5, col:31> 'float3':'vector<float, 3>' '='
   | | |-MemberExpr <col:5, col:12> 'float3':'vector<float, 3>' lvalue .pos
   | | |-MemberExpr <col:5, col:12> 'float3':'vector<float, 3>' lvalue .pos
   | | | `-DeclRefExpr <col:5> 'HSFoo' lvalue Var 'output' 'HSFoo'
   | | | `-DeclRefExpr <col:5> 'HSFoo' lvalue Var 'output' 'HSFoo'
   | | `-BinaryOperator <col:18, col:31> 'float3':'vector<float, 3>' '+'
   | | `-BinaryOperator <col:18, col:31> 'float3':'vector<float, 3>' '+'
@@ -448,14 +448,14 @@ HSFoo HSMain( InputPatch<HSFoo, 16> p,
   | |   `-ImplicitCastExpr <col:29, col:31> 'vector<float, 3>':'vector<float, 3>' <LValueToRValue>
   | |   `-ImplicitCastExpr <col:29, col:31> 'vector<float, 3>':'vector<float, 3>' <LValueToRValue>
   | |     `-HLSLVectorElementExpr <col:29, col:31> 'vector<float, 3>':'vector<float, 3>' lvalue vectorcomponent xyz
   | |     `-HLSLVectorElementExpr <col:29, col:31> 'vector<float, 3>':'vector<float, 3>' lvalue vectorcomponent xyz
   | |       `-DeclRefExpr <col:29> 'float4':'vector<float, 4>' lvalue Var 'r' 'float4':'vector<float, 4>'
   | |       `-DeclRefExpr <col:29> 'float4':'vector<float, 4>' lvalue Var 'r' 'float4':'vector<float, 4>'
-  | `-ReturnStmt <line:275:5, col:12>
+  | `-ReturnStmt <line:467:5, col:12>
   |   `-ImplicitCastExpr <col:12> 'HSFoo' <LValueToRValue>
   |   `-ImplicitCastExpr <col:12> 'HSFoo' <LValueToRValue>
   |     `-DeclRefExpr <col:12> 'HSFoo' lvalue Var 'output' 'HSFoo'
   |     `-DeclRefExpr <col:12> 'HSFoo' lvalue Var 'output' 'HSFoo'
-  |-HLSLPatchConstantFuncAttr <line:201:2, col:30> "PatchFoo"
-  |-HLSLOutputControlPointsAttr <line:200:2, col:24> 16
-  |-HLSLOutputTopologyAttr <line:199:2, col:30> "triangle_cw"
-  |-HLSLPartitioningAttr <line:198:2, col:24> "integer"
-  `-HLSLDomainAttr <line:194:2, col:15> "quad"
+  |-HLSLPatchConstantFuncAttr <line:393:2, col:30> "PatchFoo"
+  |-HLSLOutputControlPointsAttr <line:392:2, col:24> 16
+  |-HLSLOutputTopologyAttr <line:391:2, col:30> "triangle_cw"
+  |-HLSLPartitioningAttr <line:390:2, col:24> "integer"
+  `-HLSLDomainAttr <line:386:2, col:15> "quad"
 */
 */
               uint i : SV_OutputControlPointID,
               uint i : SV_OutputControlPointID,
               uint PatchID : SV_PrimitiveID )
               uint PatchID : SV_PrimitiveID )
@@ -561,13 +561,13 @@ void clipplanes_bad_scalar_swizzle();
 
 
 [clipplanes(
 [clipplanes(
 /*verify-ast
 /*verify-ast
-  HLSLClipPlanesAttr <col:2, line:390:3>
-  |-DeclRefExpr <line:387:3> 'const float4':'const vector<float, 4>' lvalue Var 'f4' 'const float4':'const vector<float, 4>'
-  |-ArraySubscriptExpr <line:388:3, col:8> 'const float4':'const vector<float, 4>' lvalue
+  HLSLClipPlanesAttr <col:2, line:582:3>
+  |-DeclRefExpr <line:579:3> 'const float4':'const vector<float, 4>' lvalue Var 'f4' 'const float4':'const vector<float, 4>'
+  |-ArraySubscriptExpr <line:580:3, col:8> 'const float4':'const vector<float, 4>' lvalue
   | |-ImplicitCastExpr <col:3> 'const float4 [2]' <LValueToRValue>
   | |-ImplicitCastExpr <col:3> 'const float4 [2]' <LValueToRValue>
   | | `-DeclRefExpr <col:3> 'const float4 [2]' lvalue Var 'cp4' 'const float4 [2]'
   | | `-DeclRefExpr <col:3> 'const float4 [2]' lvalue Var 'cp4' 'const float4 [2]'
   | `-IntegerLiteral <col:7> 'literal int' 0
   | `-IntegerLiteral <col:7> 'literal int' 0
-  |-ArraySubscriptExpr <line:389:3, col:11> 'float4':'vector<float, 4>' lvalue
+  |-ArraySubscriptExpr <line:581:3, col:11> 'float4':'vector<float, 4>' lvalue
   | |-ImplicitCastExpr <col:3, col:6> 'float4 [5]' <LValueToRValue>
   | |-ImplicitCastExpr <col:3, col:6> 'float4 [5]' <LValueToRValue>
   | | `-MemberExpr <col:3, col:6> 'float4 const[5]' lvalue .cp5
   | | `-MemberExpr <col:3, col:6> 'float4 const[5]' lvalue .cp5
   | |   `-DeclRefExpr <col:3> 'const global_struct' lvalue Var 'gs' 'const global_struct'
   | |   `-DeclRefExpr <col:3> 'const global_struct' lvalue Var 'gs' 'const global_struct'
@@ -585,21 +585,21 @@ float4 clipplanes_good();
 
 
 [clipplanes(
 [clipplanes(
 /*verify-ast
 /*verify-ast
-  HLSLClipPlanesAttr <col:2, line:424:3>
-  |-ParenExpr <line:420:3, col:6> 'const float4':'const vector<float, 4>' lvalue
+  HLSLClipPlanesAttr <col:2, line:616:3>
+  |-ParenExpr <line:612:3, col:6> 'const float4':'const vector<float, 4>' lvalue
   | `-DeclRefExpr <col:4> 'const float4':'const vector<float, 4>' lvalue Var 'f4' 'const float4':'const vector<float, 4>'
   | `-DeclRefExpr <col:4> 'const float4':'const vector<float, 4>' lvalue Var 'f4' 'const float4':'const vector<float, 4>'
-  |-ArraySubscriptExpr <line:421:3, col:10> 'const float4':'const vector<float, 4>' lvalue
+  |-ArraySubscriptExpr <line:613:3, col:10> 'const float4':'const vector<float, 4>' lvalue
   | |-ImplicitCastExpr <col:3> 'const float4 [2]' <LValueToRValue>
   | |-ImplicitCastExpr <col:3> 'const float4 [2]' <LValueToRValue>
   | | `-DeclRefExpr <col:3> 'const float4 [2]' lvalue Var 'cp4' 'const float4 [2]'
   | | `-DeclRefExpr <col:3> 'const float4 [2]' lvalue Var 'cp4' 'const float4 [2]'
   | `-ParenExpr <col:7, col:9> 'literal int'
   | `-ParenExpr <col:7, col:9> 'literal int'
   |   `-IntegerLiteral <col:8> 'literal int' 0
   |   `-IntegerLiteral <col:8> 'literal int' 0
-  |-ArraySubscriptExpr <line:422:3, col:13> 'float4':'vector<float, 4>' lvalue
+  |-ArraySubscriptExpr <line:614:3, col:13> 'float4':'vector<float, 4>' lvalue
   | |-ImplicitCastExpr <col:3, col:8> 'float4 [5]' <LValueToRValue>
   | |-ImplicitCastExpr <col:3, col:8> 'float4 [5]' <LValueToRValue>
   | | `-MemberExpr <col:3, col:8> 'float4 const[5]' lvalue .cp5
   | | `-MemberExpr <col:3, col:8> 'float4 const[5]' lvalue .cp5
   | |   `-ParenExpr <col:3, col:6> 'const global_struct' lvalue
   | |   `-ParenExpr <col:3, col:6> 'const global_struct' lvalue
   | |     `-DeclRefExpr <col:4> 'const global_struct' lvalue Var 'gs' 'const global_struct'
   | |     `-DeclRefExpr <col:4> 'const global_struct' lvalue Var 'gs' 'const global_struct'
   | `-IntegerLiteral <col:12> 'literal int' 2
   | `-IntegerLiteral <col:12> 'literal int' 2
-  |-ParenExpr <line:423:3, col:15> 'float4':'vector<float, 4>' lvalue
+  |-ParenExpr <line:615:3, col:15> 'float4':'vector<float, 4>' lvalue
   | `-ArraySubscriptExpr <col:4, col:14> 'float4':'vector<float, 4>' lvalue
   | `-ArraySubscriptExpr <col:4, col:14> 'float4':'vector<float, 4>' lvalue
   |   |-ImplicitCastExpr <col:4, col:9> 'float4 [5]' <LValueToRValue>
   |   |-ImplicitCastExpr <col:4, col:9> 'float4 [5]' <LValueToRValue>
   |   | `-MemberExpr <col:4, col:9> 'float4 const[5]' lvalue .cp5
   |   | `-MemberExpr <col:4, col:9> 'float4 const[5]' lvalue .cp5

+ 13 - 13
tools/clang/test/HLSL/builtin-types-no-inheritance.hlsl

@@ -1,20 +1,20 @@
 // RUN: %clang_cc1 -Wno-unused-value -fsyntax-only -ffreestanding -verify -verify-ignore-unexpected=note %s
 // RUN: %clang_cc1 -Wno-unused-value -fsyntax-only -ffreestanding -verify -verify-ignore-unexpected=note %s
 
 
-struct F2 : float2 {}; // expected-error {{base 'vector' is marked 'final'}}
-struct F4x4 : float4x4 {}; // expected-error {{base 'matrix' is marked 'final'}}
-struct Tex3D : Texture3D<float> {};  // expected-error {{base 'Texture3D' is marked 'final'}}
-struct BABuf : ByteAddressBuffer {}; // expected-error {{base 'ByteAddressBuffer' is marked 'final'}}
-struct StructBuf : StructuredBuffer<int> {}; // expected-error {{base 'StructuredBuffer' is marked 'final'}}
-struct Samp : SamplerState {}; // expected-error {{base 'SamplerState' is marked 'final'}}
+struct F2 : float2 {}; // expected-error {{base 'vector' is marked 'final'}} fxc-error {{X3094: base type is not a struct, class or interface}}
+struct F4x4 : float4x4 {}; // expected-error {{base 'matrix' is marked 'final'}} fxc-error {{X3094: base type is not a struct, class or interface}}
+struct Tex3D : Texture3D<float> {};  // expected-error {{base 'Texture3D' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'Texture3D'}}
+struct BABuf : ByteAddressBuffer {}; // expected-error {{base 'ByteAddressBuffer' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'ByteAddressBuffer'}}
+struct StructBuf : StructuredBuffer<int> {}; // expected-error {{base 'StructuredBuffer' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'StructuredBuffer'}}
+struct Samp : SamplerState {}; // expected-error {{base 'SamplerState' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'SamplerState'}}
 
 
 struct Vertex { float3 pos : POSITION; };
 struct Vertex { float3 pos : POSITION; };
-struct GSTS : TriangleStream<Vertex> {}; // expected-error {{base 'TriangleStream' is marked 'final'}}
-struct HSIP : InputPatch<Vertex, 16> {}; // expected-error {{base 'InputPatch' is marked 'final'}}
-struct HSOP : OutputPatch<Vertex, 16> {}; // expected-error {{base 'OutputPatch' is marked 'final'}}
+struct GSTS : TriangleStream<Vertex> {}; // expected-error {{base 'TriangleStream' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'TriangleStream'}}
+struct HSIP : InputPatch<Vertex, 16> {}; // expected-error {{base 'InputPatch' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'InputPatch'}}
+struct HSOP : OutputPatch<Vertex, 16> {}; // expected-error {{base 'OutputPatch' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'OutputPatch'}}
 
 
-struct RD : RayDesc {}; // expected-error {{base 'RayDesc' is marked 'final'}}
-struct BITIA : BuiltInTriangleIntersectionAttributes {}; // expected-error {{base 'BuiltInTriangleIntersectionAttributes' is marked 'final'}}
-struct RTAS : RaytracingAccelerationStructure {}; // expected-error {{base 'RaytracingAccelerationStructure' is marked 'final'}}
-struct GRS : GlobalRootSignature {}; // expected-error {{base 'GlobalRootSignature' is marked 'final'}}
+struct RD : RayDesc {}; // expected-error {{base 'RayDesc' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'RayDesc'}}
+struct BITIA : BuiltInTriangleIntersectionAttributes {}; // expected-error {{base 'BuiltInTriangleIntersectionAttributes' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'BuiltInTriangleIntersectionAttributes'}}
+struct RTAS : RaytracingAccelerationStructure {}; // expected-error {{base 'RaytracingAccelerationStructure' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'RaytracingAccelerationStructure'}}
+struct GRS : GlobalRootSignature {}; // expected-error {{base 'GlobalRootSignature' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'GlobalRootSignature'}}
 
 
 void main() {}
 void main() {}

+ 6 - 6
tools/clang/test/HLSL/conversions-non-numeric-aggregates.hlsl

@@ -7,13 +7,13 @@ struct ObjStruct { Buffer a; };
 
 
 void main()
 void main()
 {
 {
-  (Buffer[1])0; /* expected-error {{cannot convert from 'literal int' to 'Buffer [1]'}} */
-  (ObjStruct)0; /* expected-error {{cannot convert from 'literal int' to 'ObjStruct'}} */
-  (Buffer[1])(int[1])0; /* expected-error {{cannot convert from 'int [1]' to 'Buffer [1]'}} */
-  (ObjStruct)(NumStruct)0; /* expected-error {{cannot convert from 'NumStruct' to 'ObjStruct'}} */
+  (Buffer[1])0; /* expected-error {{cannot convert from 'literal int' to 'Buffer [1]'}} fxc-error {{X3017: cannot convert from 'int' to 'Buffer<float4>[1]'}} */
+  (ObjStruct)0; /* expected-error {{cannot convert from 'literal int' to 'ObjStruct'}} fxc-error {{X3017: cannot convert from 'int' to 'struct ObjStruct'}} */
+  (Buffer[1])(int[1])0; /* expected-error {{cannot convert from 'int [1]' to 'Buffer [1]'}} fxc-error {{X3017: cannot convert from 'const int[1]' to 'Buffer<float4>[1]'}} */
+  (ObjStruct)(NumStruct)0; /* expected-error {{cannot convert from 'NumStruct' to 'ObjStruct'}} fxc-error {{X3017: cannot convert from 'const struct NumStruct' to 'struct ObjStruct'}} */
 
 
   Buffer oa1[1];
   Buffer oa1[1];
   ObjStruct os1;
   ObjStruct os1;
-  (int)oa1; /* expected-error {{cannot convert from 'Buffer [1]' to 'int'}} */
-  (int)os1; /* expected-error {{cannot convert from 'ObjStruct' to 'int'}} */
+  (int)oa1; /* expected-error {{cannot convert from 'Buffer [1]' to 'int'}} fxc-error {{X3017: cannot convert from 'Buffer<float4>[1]' to 'int'}} */
+  (int)os1; /* expected-error {{cannot convert from 'ObjStruct' to 'int'}} fxc-error {{X3017: cannot convert from 'struct ObjStruct' to 'int'}} */
 }
 }

+ 7 - 7
tools/clang/test/HLSL/incomp_array_err.hlsl

@@ -2,28 +2,28 @@
 
 
 // Verify error on on incomplete array in a struct or class
 // Verify error on on incomplete array in a struct or class
 
 
-typedef const int inta[];
+typedef const int inta[];                                   /* fxc-error {{X3072: array dimensions of type must be explicit}} */
 
 
-static inta s_test1 = {1, 2, 3};
+static inta s_test1 = {1, 2, 3};                            /* fxc-error {{X3000: unrecognized identifier 'inta'}} */
 
 
 static int s_test2[] = { 4, 5, 6 };
 static int s_test2[] = { 4, 5, 6 };
 
 
 struct foo1 {
 struct foo1 {
   float4 member;
   float4 member;
-  inta a;   // expected-error {{array dimensions of struct/class members must be explicit}}
+  inta a;   // expected-error {{array dimensions of struct/class members must be explicit}} fxc-error {{X3000: unrecognized identifier 'inta'}}
 };
 };
 
 
 struct foo2 {
 struct foo2 {
-  int a[];  // expected-error {{array dimensions of struct/class members must be explicit}}
+  int a[];  // expected-error {{array dimensions of struct/class members must be explicit}} fxc-error {{X3072: 'foo2::a': array dimensions of struct/class members must be explicit}}
   float4 member;
   float4 member;
 };
 };
 
 
 class foo3 {
 class foo3 {
   float4 member;
   float4 member;
-  inta a;   // expected-error {{array dimensions of struct/class members must be explicit}}
+  inta a;   // expected-error {{array dimensions of struct/class members must be explicit}} fxc-error {{X3000: unrecognized identifier 'inta'}}
 };
 };
 
 
 class foo4 {
 class foo4 {
   float4 member;
   float4 member;
-  int a[];  // expected-error {{array dimensions of struct/class members must be explicit}}
-};
+  int a[];  // expected-error {{array dimensions of struct/class members must be explicit}} fxc-error {{X3072: 'foo4::a': array dimensions of struct/class members must be explicit}}
+};

+ 214 - 28
tools/clang/test/HLSL/indexing-operator.hlsl

@@ -3,6 +3,25 @@
 // To test with the classic compiler, run
 // To test with the classic compiler, run
 // %sdxroot%\tools\x86\fxc.exe /T vs_5_1 indexing-operator.hlsl
 // %sdxroot%\tools\x86\fxc.exe /T vs_5_1 indexing-operator.hlsl
 
 
+/* Expected notes with no locations (implicit built-in):
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+  expected-note@? {{function 'operator[]<const vector<float, 4> &>' which returns const-qualified type 'const vector<float, 4> &' declared here}}
+*/
+
 Buffer g_b;
 Buffer g_b;
 StructuredBuffer<float4> g_sb;
 StructuredBuffer<float4> g_sb;
 Texture1D g_t1d;
 Texture1D g_t1d;
@@ -123,6 +142,55 @@ float4 test_scalar_indexing()
   f4 += g_tc[0]; // expected-error {{type 'TextureCube' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   f4 += g_tc[0]; // expected-error {{type 'TextureCube' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   // fxc  error X3121: array, matrix, vector, or indexable object type expected in index expression
   // fxc  error X3121: array, matrix, vector, or indexable object type expected in index expression
   f4 += g_tca[0]; // expected-error {{type 'TextureCubeArray' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   f4 += g_tca[0]; // expected-error {{type 'TextureCubeArray' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
+
+  g_b[0] = f4;          /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t1d[0] = f4;        /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_sb[0] = f4;         /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+
+  g_rw_sb[0] = f4;
+  /*verify-ast
+    BinaryOperator <col:3, col:16> 'vector<float, 4>' '='
+    |-CXXOperatorCallExpr <col:3, col:12> 'vector<float, 4>' lvalue
+    | |-ImplicitCastExpr <col:10, col:12> 'vector<float, 4> &(*)(unsigned int) const' <FunctionToPointerDecay>
+    | | `-DeclRefExpr <col:10, col:12> 'vector<float, 4> &(unsigned int) const' lvalue CXXMethod 'operator[]' 'vector<float, 4> &(unsigned int) const'
+    | |-ImplicitCastExpr <col:3> 'const RWStructuredBuffer<vector<float, 4> >' lvalue <NoOp>
+    | | `-DeclRefExpr <col:3> 'RWStructuredBuffer<float4>':'RWStructuredBuffer<vector<float, 4> >' lvalue Var 'g_rw_sb' 'RWStructuredBuffer<float4>':'RWStructuredBuffer<vector<float, 4> >'
+    | `-ImplicitCastExpr <col:11> 'unsigned int' <IntegralCast>
+    |   `-IntegerLiteral <col:11> 'literal int' 0
+    `-ImplicitCastExpr <col:16> 'float4':'vector<float, 4>' <LValueToRValue>
+      `-DeclRefExpr <col:16> 'float4':'vector<float, 4>' lvalue Var 'f4' 'float4':'vector<float, 4>'
+  */
+  g_rw_b[0] = f4;
+  /*verify-ast
+    BinaryOperator <col:3, col:15> 'vector<float, 4>' '='
+    |-CXXOperatorCallExpr <col:3, col:11> 'vector<float, 4>' lvalue
+    | |-ImplicitCastExpr <col:9, col:11> 'vector<float, 4> &(*)(unsigned int) const' <FunctionToPointerDecay>
+    | | `-DeclRefExpr <col:9, col:11> 'vector<float, 4> &(unsigned int) const' lvalue CXXMethod 'operator[]' 'vector<float, 4> &(unsigned int) const'
+    | |-ImplicitCastExpr <col:3> 'const RWBuffer<vector<float, 4> >' lvalue <NoOp>
+    | | `-DeclRefExpr <col:3> 'RWBuffer<float4>':'RWBuffer<vector<float, 4> >' lvalue Var 'g_rw_b' 'RWBuffer<float4>':'RWBuffer<vector<float, 4> >'
+    | `-ImplicitCastExpr <col:10> 'unsigned int' <IntegralCast>
+    |   `-IntegerLiteral <col:10> 'literal int' 0
+    `-ImplicitCastExpr <col:15> 'float4':'vector<float, 4>' <LValueToRValue>
+      `-DeclRefExpr <col:15> 'float4':'vector<float, 4>' lvalue Var 'f4' 'float4':'vector<float, 4>'
+  */
+  g_rw_t1d[0] = f4;
+  /*verify-ast
+    BinaryOperator <col:3, col:17> 'vector<float, 4>' '='
+    |-CXXOperatorCallExpr <col:3, col:13> 'vector<float, 4>' lvalue
+    | |-ImplicitCastExpr <col:11, col:13> 'vector<float, 4> &(*)(unsigned int) const' <FunctionToPointerDecay>
+    | | `-DeclRefExpr <col:11, col:13> 'vector<float, 4> &(unsigned int) const' lvalue CXXMethod 'operator[]' 'vector<float, 4> &(unsigned int) const'
+    | |-ImplicitCastExpr <col:3> 'const RWTexture1D<vector<float, 4> >' lvalue <NoOp>
+    | | `-DeclRefExpr <col:3> 'RWTexture1D<float4>':'RWTexture1D<vector<float, 4> >' lvalue Var 'g_rw_t1d' 'RWTexture1D<float4>':'RWTexture1D<vector<float, 4> >'
+    | `-ImplicitCastExpr <col:12> 'unsigned int' <IntegralCast>
+    |   `-IntegerLiteral <col:12> 'literal int' 0
+    `-ImplicitCastExpr <col:17> 'float4':'vector<float, 4>' <LValueToRValue>
+      `-DeclRefExpr <col:17> 'float4':'vector<float, 4>' lvalue Var 'f4' 'float4':'vector<float, 4>'
+  */
+  g_rw_t1da[0] = f4;    /* expected-error {{no viable overloaded operator[] for type 'RWTexture1DArray<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'literal int' to 'vector<uint, 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t2d[0] = f4;     /* expected-error {{no viable overloaded operator[] for type 'RWTexture2D<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'literal int' to 'vector<uint, 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t2da[0] = f4;    /* expected-error {{no viable overloaded operator[] for type 'RWTexture2DArray<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'literal int' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t3d[0] = f4;     /* expected-error {{no viable overloaded operator[] for type 'RWTexture3D<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'literal int' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+
   return f4;
   return f4;
 }
 }
 
 
@@ -175,6 +243,45 @@ float4 test_vector2_indexing()
   f4 += g_tc[offset]; // expected-error {{type 'TextureCube' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   f4 += g_tc[offset]; // expected-error {{type 'TextureCube' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   // fxc error X3121: array, matrix, vector, or indexable object type expected in index expression
   // fxc error X3121: array, matrix, vector, or indexable object type expected in index expression
   f4 += g_tca[offset]; // expected-error {{type 'TextureCubeArray' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   f4 += g_tca[offset]; // expected-error {{type 'TextureCubeArray' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
+
+  g_t1da[offset] = f4;    /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t2d[offset] = f4;     /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t2dms[offset] = f4;   /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+
+  g_rw_sb[offset] = f4;   /* expected-error {{no viable overloaded operator[] for type 'RWStructuredBuffer<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'int2' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_b[offset] = f4;    /* expected-error {{no viable overloaded operator[] for type 'RWBuffer<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'int2' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t1d[offset] = f4;  /* expected-error {{no viable overloaded operator[] for type 'RWTexture1D<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'int2' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t1da[offset] = f4;
+  /*verify-ast
+    BinaryOperator <col:3, col:23> 'vector<float, 4>' '='
+    |-CXXOperatorCallExpr <col:3, col:19> 'vector<float, 4>' lvalue
+    | |-ImplicitCastExpr <col:12, col:19> 'vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
+    | | `-DeclRefExpr <col:12, col:19> 'vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'vector<float, 4> &(vector<uint, 2>) const'
+    | |-ImplicitCastExpr <col:3> 'const RWTexture1DArray<vector<float, 4> >' lvalue <NoOp>
+    | | `-DeclRefExpr <col:3> 'RWTexture1DArray<float4>':'RWTexture1DArray<vector<float, 4> >' lvalue Var 'g_rw_t1da' 'RWTexture1DArray<float4>':'RWTexture1DArray<vector<float, 4> >'
+    | `-ImplicitCastExpr <col:13> 'vector<unsigned int, 2>' <HLSLCC_IntegralCast>
+    |   `-ImplicitCastExpr <col:13> 'int2':'vector<int, 2>' <LValueToRValue>
+    |     `-DeclRefExpr <col:13> 'int2':'vector<int, 2>' lvalue Var 'offset' 'int2':'vector<int, 2>'
+    `-ImplicitCastExpr <col:23> 'float4':'vector<float, 4>' <LValueToRValue>
+      `-DeclRefExpr <col:23> 'float4':'vector<float, 4>' lvalue Var 'f4' 'float4':'vector<float, 4>'
+  */
+  g_rw_t2d[offset] = f4;
+  /*verify-ast
+    BinaryOperator <col:3, col:22> 'vector<float, 4>' '='
+    |-CXXOperatorCallExpr <col:3, col:18> 'vector<float, 4>' lvalue
+    | |-ImplicitCastExpr <col:11, col:18> 'vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
+    | | `-DeclRefExpr <col:11, col:18> 'vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'vector<float, 4> &(vector<uint, 2>) const'
+    | |-ImplicitCastExpr <col:3> 'const RWTexture2D<vector<float, 4> >' lvalue <NoOp>
+    | | `-DeclRefExpr <col:3> 'RWTexture2D<float4>':'RWTexture2D<vector<float, 4> >' lvalue Var 'g_rw_t2d' 'RWTexture2D<float4>':'RWTexture2D<vector<float, 4> >'
+    | `-ImplicitCastExpr <col:12> 'vector<unsigned int, 2>' <HLSLCC_IntegralCast>
+    |   `-ImplicitCastExpr <col:12> 'int2':'vector<int, 2>' <LValueToRValue>
+    |     `-DeclRefExpr <col:12> 'int2':'vector<int, 2>' lvalue Var 'offset' 'int2':'vector<int, 2>'
+    `-ImplicitCastExpr <col:22> 'float4':'vector<float, 4>' <LValueToRValue>
+      `-DeclRefExpr <col:22> 'float4':'vector<float, 4>' lvalue Var 'f4' 'float4':'vector<float, 4>'
+  */
+  g_rw_t2da[offset] = f4; /* expected-error {{no viable overloaded operator[] for type 'RWTexture2DArray<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'vector<int, 2>' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t3d[offset] = f4;  /* expected-error {{no viable overloaded operator[] for type 'RWTexture3D<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'vector<int, 2>' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+
   return f4;
   return f4;
 }
 }
 
 
@@ -240,6 +347,45 @@ float4 test_vector3_indexing()
   f4 += g_tc[offset]; // expected-error {{type 'TextureCube' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   f4 += g_tc[offset]; // expected-error {{type 'TextureCube' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   // fxc error X3121: array, matrix, vector, or indexable object type expected in index expression
   // fxc error X3121: array, matrix, vector, or indexable object type expected in index expression
   f4 += g_tca[offset]; // expected-error {{type 'TextureCubeArray' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
   f4 += g_tca[offset]; // expected-error {{type 'TextureCubeArray' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
+
+  g_t2da[offset] = f4;      /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t2dmsa[offset] = f4;    /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t3d[offset] = f4;       /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+
+  g_rw_sb[offset] = f4;     /* expected-error {{no viable overloaded operator[] for type 'RWStructuredBuffer<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'int3' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_b[offset] = f4;      /* expected-error {{no viable overloaded operator[] for type 'RWBuffer<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'int3' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t1d[offset] = f4;    /* expected-error {{no viable overloaded operator[] for type 'RWTexture1D<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'int3' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t1da[offset] = f4;   /* expected-error {{no viable overloaded operator[] for type 'RWTexture1DArray<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'vector<int, 3>' to 'vector<uint, 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t2d[offset] = f4;    /* expected-error {{no viable overloaded operator[] for type 'RWTexture2D<float4>'}} expected-note {{candidate function [with element = vector<float, 4> &] not viable: no known conversion from 'vector<int, 3>' to 'vector<uint, 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  g_rw_t2da[offset] = f4;
+  /*verify-ast
+    BinaryOperator <col:3, col:23> 'vector<float, 4>' '='
+    |-CXXOperatorCallExpr <col:3, col:19> 'vector<float, 4>' lvalue
+    | |-ImplicitCastExpr <col:12, col:19> 'vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
+    | | `-DeclRefExpr <col:12, col:19> 'vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'vector<float, 4> &(vector<uint, 3>) const'
+    | |-ImplicitCastExpr <col:3> 'const RWTexture2DArray<vector<float, 4> >' lvalue <NoOp>
+    | | `-DeclRefExpr <col:3> 'RWTexture2DArray<float4>':'RWTexture2DArray<vector<float, 4> >' lvalue Var 'g_rw_t2da' 'RWTexture2DArray<float4>':'RWTexture2DArray<vector<float, 4> >'
+    | `-ImplicitCastExpr <col:13> 'vector<unsigned int, 3>' <HLSLCC_IntegralCast>
+    |   `-ImplicitCastExpr <col:13> 'int3':'vector<int, 3>' <LValueToRValue>
+    |     `-DeclRefExpr <col:13> 'int3':'vector<int, 3>' lvalue Var 'offset' 'int3':'vector<int, 3>'
+    `-ImplicitCastExpr <col:23> 'float4':'vector<float, 4>' <LValueToRValue>
+      `-DeclRefExpr <col:23> 'float4':'vector<float, 4>' lvalue Var 'f4' 'float4':'vector<float, 4>'
+  */
+  g_rw_t3d[offset] = f4;
+  /*verify-ast
+    BinaryOperator <col:3, col:22> 'vector<float, 4>' '='
+    |-CXXOperatorCallExpr <col:3, col:18> 'vector<float, 4>' lvalue
+    | |-ImplicitCastExpr <col:11, col:18> 'vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
+    | | `-DeclRefExpr <col:11, col:18> 'vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'vector<float, 4> &(vector<uint, 3>) const'
+    | |-ImplicitCastExpr <col:3> 'const RWTexture3D<vector<float, 4> >' lvalue <NoOp>
+    | | `-DeclRefExpr <col:3> 'RWTexture3D<float4>':'RWTexture3D<vector<float, 4> >' lvalue Var 'g_rw_t3d' 'RWTexture3D<float4>':'RWTexture3D<vector<float, 4> >'
+    | `-ImplicitCastExpr <col:12> 'vector<unsigned int, 3>' <HLSLCC_IntegralCast>
+    |   `-ImplicitCastExpr <col:12> 'int3':'vector<int, 3>' <LValueToRValue>
+    |     `-DeclRefExpr <col:12> 'int3':'vector<int, 3>' lvalue Var 'offset' 'int3':'vector<int, 3>'
+    `-ImplicitCastExpr <col:22> 'float4':'vector<float, 4>' <LValueToRValue>
+      `-DeclRefExpr <col:22> 'float4':'vector<float, 4>' lvalue Var 'f4' 'float4':'vector<float, 4>'
+  */
+
   return f4;
   return f4;
 }
 }
 
 
@@ -270,6 +416,21 @@ float4 test_mips_indexing()
   f4 += g_tc.mips[offset]; // expected-error {{no member named 'mips' in 'TextureCube<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_tc.mips[offset]; // expected-error {{no member named 'mips' in 'TextureCube<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   // fxc error X3018: invalid subscript 'mips'
   // fxc error X3018: invalid subscript 'mips'
   f4 += g_tca.mips[offset]; // expected-error {{no member named 'mips' in 'TextureCubeArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_tca.mips[offset]; // expected-error {{no member named 'mips' in 'TextureCubeArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
+
+  g_t1d.mips[offset] = f4;      /* expected-error {{cannot convert from 'float4' to 'Texture1D<vector<float, 4> >::mips_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */
+  g_t1da.mips[offset] = f4;     /* expected-error {{cannot convert from 'float4' to 'Texture1DArray<vector<float, 4> >::mips_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */
+  g_t2d.mips[offset] = f4;      /* expected-error {{cannot convert from 'float4' to 'Texture2D<vector<float, 4> >::mips_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */
+  g_t2da.mips[offset] = f4;     /* expected-error {{cannot convert from 'float4' to 'Texture2DArray<vector<float, 4> >::mips_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */
+  g_t3d.mips[offset] = f4;      /* expected-error {{cannot convert from 'float4' to 'Texture3D<vector<float, 4> >::mips_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */
+
+  g_rw_sb.mips[offset] = f4;    /* expected-error {{no member named 'mips' in 'RWStructuredBuffer<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}} */
+  g_rw_b.mips[offset] = f4;     /* expected-error {{no member named 'mips' in 'RWBuffer<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}} */
+  g_rw_t1d.mips[offset] = f4;   /* expected-error {{no member named 'mips' in 'RWTexture1D<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}} */
+  g_rw_t1da.mips[offset] = f4;  /* expected-error {{no member named 'mips' in 'RWTexture1DArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}} */
+  g_rw_t2d.mips[offset] = f4;   /* expected-error {{no member named 'mips' in 'RWTexture2D<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}} */
+  g_rw_t2da.mips[offset] = f4;  /* expected-error {{no member named 'mips' in 'RWTexture2DArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}} */
+  g_rw_t3d.mips[offset] = f4;   /* expected-error {{no member named 'mips' in 'RWTexture3D<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}} */
+
   return f4;
   return f4;
 }
 }
 
 
@@ -280,6 +441,7 @@ float4 test_mips_double_indexing()
   uint pos = 1;
   uint pos = 1;
   uint2 pos2 = { 1, 2 };
   uint2 pos2 = { 1, 2 };
   uint3 pos3 = { 1, 2, 3 };
   uint3 pos3 = { 1, 2, 3 };
+  uint4 pos4 = { 1, 2, 3, 4 };
   float4 f4;
   float4 f4;
   // fxc error X3018: invalid subscript 'mips'
   // fxc error X3018: invalid subscript 'mips'
   f4 += g_b.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Buffer<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_b.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Buffer<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
@@ -291,10 +453,10 @@ float4 test_mips_double_indexing()
       `-CXXOperatorCallExpr <col:9, col:33> 'const vector<float, 4>' lvalue
       `-CXXOperatorCallExpr <col:9, col:33> 'const vector<float, 4>' lvalue
         |-ImplicitCastExpr <col:29, col:33> 'const vector<float, 4> &(*)(unsigned int) const' <FunctionToPointerDecay>
         |-ImplicitCastExpr <col:29, col:33> 'const vector<float, 4> &(*)(unsigned int) const' <FunctionToPointerDecay>
         | `-DeclRefExpr <col:29, col:33> 'const vector<float, 4> &(unsigned int) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(unsigned int) const'
         | `-DeclRefExpr <col:29, col:33> 'const vector<float, 4> &(unsigned int) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(unsigned int) const'
-        |-ImplicitCastExpr <col:9, col:28> 'const Texture1D<vector<float, 4> >::mips_slice_type' xvalue <NoOp>
-        | `-CXXOperatorCallExpr <col:9, col:28> 'Texture1D<vector<float, 4> >::mips_slice_type' xvalue
-        |   |-ImplicitCastExpr <col:19, col:28> 'Texture1D<vector<float, 4> >::mips_slice_type &&(*)(unsigned int) const' <FunctionToPointerDecay>
-        |   | `-DeclRefExpr <col:19, col:28> 'Texture1D<vector<float, 4> >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1D<vector<float, 4> >::mips_slice_type &&(unsigned int) const'
+        |-ImplicitCastExpr <col:9, col:28> 'const Texture1D<vector<float, 4> >::mips_slice_type' lvalue <NoOp>
+        | `-CXXOperatorCallExpr <col:9, col:28> 'Texture1D<vector<float, 4> >::mips_slice_type' lvalue
+        |   |-ImplicitCastExpr <col:19, col:28> 'Texture1D<vector<float, 4> >::mips_slice_type &(*)(unsigned int) const' <FunctionToPointerDecay>
+        |   | `-DeclRefExpr <col:19, col:28> 'Texture1D<vector<float, 4> >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1D<vector<float, 4> >::mips_slice_type &(unsigned int) const'
         |   |-ImplicitCastExpr <col:9, col:15> 'const Texture1D<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   |-ImplicitCastExpr <col:9, col:15> 'const Texture1D<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   | `-MemberExpr <col:9, col:15> 'Texture1D<vector<float, 4> >::mips_type' lvalue .mips
         |   | `-MemberExpr <col:9, col:15> 'Texture1D<vector<float, 4> >::mips_type' lvalue .mips
         |   |   `-DeclRefExpr <col:9> 'Texture1D':'Texture1D<vector<float, 4> >' lvalue Var 'g_t1d' 'Texture1D':'Texture1D<vector<float, 4> >'
         |   |   `-DeclRefExpr <col:9> 'Texture1D':'Texture1D<vector<float, 4> >' lvalue Var 'g_t1d' 'Texture1D':'Texture1D<vector<float, 4> >'
@@ -303,6 +465,9 @@ float4 test_mips_double_indexing()
         `-ImplicitCastExpr <col:30> 'uint':'unsigned int' <LValueToRValue>
         `-ImplicitCastExpr <col:30> 'uint':'unsigned int' <LValueToRValue>
           `-DeclRefExpr <col:30> 'uint':'unsigned int' lvalue Var 'pos' 'uint':'unsigned int'
           `-DeclRefExpr <col:30> 'uint':'unsigned int' lvalue Var 'pos' 'uint':'unsigned int'
   */
   */
+  f4 += g_t1d.mips[mipSlice][pos2]; /* expected-error {{no viable overloaded operator[] for type 'Texture1D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint2' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  f4 += g_t1d.mips[mipSlice][pos3]; /* expected-error {{no viable overloaded operator[] for type 'Texture1D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint3' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  f4 += g_t1d.mips[mipSlice][pos4]; /* expected-error {{no viable overloaded operator[] for type 'Texture1D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint4' to 'unsigned int' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
   // fxc error X3018: invalid subscript 'mips'
   // fxc error X3018: invalid subscript 'mips'
   f4 += g_sb.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'StructuredBuffer<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_sb.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'StructuredBuffer<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
@@ -315,10 +480,10 @@ float4 test_mips_double_indexing()
       `-CXXOperatorCallExpr <col:9, col:35> 'const vector<float, 4>' lvalue
       `-CXXOperatorCallExpr <col:9, col:35> 'const vector<float, 4>' lvalue
         |-ImplicitCastExpr <col:30, col:35> 'const vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
         |-ImplicitCastExpr <col:30, col:35> 'const vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
         | `-DeclRefExpr <col:30, col:35> 'const vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 2>) const'
         | `-DeclRefExpr <col:30, col:35> 'const vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 2>) const'
-        |-ImplicitCastExpr <col:9, col:29> 'const Texture1DArray<vector<float, 4> >::mips_slice_type' xvalue <NoOp>
-        | `-CXXOperatorCallExpr <col:9, col:29> 'Texture1DArray<vector<float, 4> >::mips_slice_type' xvalue
-        |   |-ImplicitCastExpr <col:20, col:29> 'Texture1DArray<vector<float, 4> >::mips_slice_type &&(*)(unsigned int) const' <FunctionToPointerDecay>
-        |   | `-DeclRefExpr <col:20, col:29> 'Texture1DArray<vector<float, 4> >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1DArray<vector<float, 4> >::mips_slice_type &&(unsigned int) const'
+        |-ImplicitCastExpr <col:9, col:29> 'const Texture1DArray<vector<float, 4> >::mips_slice_type' lvalue <NoOp>
+        | `-CXXOperatorCallExpr <col:9, col:29> 'Texture1DArray<vector<float, 4> >::mips_slice_type' lvalue
+        |   |-ImplicitCastExpr <col:20, col:29> 'Texture1DArray<vector<float, 4> >::mips_slice_type &(*)(unsigned int) const' <FunctionToPointerDecay>
+        |   | `-DeclRefExpr <col:20, col:29> 'Texture1DArray<vector<float, 4> >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1DArray<vector<float, 4> >::mips_slice_type &(unsigned int) const'
         |   |-ImplicitCastExpr <col:9, col:16> 'const Texture1DArray<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   |-ImplicitCastExpr <col:9, col:16> 'const Texture1DArray<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   | `-MemberExpr <col:9, col:16> 'Texture1DArray<vector<float, 4> >::mips_type' lvalue .mips
         |   | `-MemberExpr <col:9, col:16> 'Texture1DArray<vector<float, 4> >::mips_type' lvalue .mips
         |   |   `-DeclRefExpr <col:9> 'Texture1DArray':'Texture1DArray<vector<float, 4> >' lvalue Var 'g_t1da' 'Texture1DArray':'Texture1DArray<vector<float, 4> >'
         |   |   `-DeclRefExpr <col:9> 'Texture1DArray':'Texture1DArray<vector<float, 4> >' lvalue Var 'g_t1da' 'Texture1DArray':'Texture1DArray<vector<float, 4> >'
@@ -327,6 +492,8 @@ float4 test_mips_double_indexing()
         `-ImplicitCastExpr <col:31> 'uint2':'vector<unsigned int, 2>' <LValueToRValue>
         `-ImplicitCastExpr <col:31> 'uint2':'vector<unsigned int, 2>' <LValueToRValue>
           `-DeclRefExpr <col:31> 'uint2':'vector<unsigned int, 2>' lvalue Var 'pos2' 'uint2':'vector<unsigned int, 2>'
           `-DeclRefExpr <col:31> 'uint2':'vector<unsigned int, 2>' lvalue Var 'pos2' 'uint2':'vector<unsigned int, 2>'
   */
   */
+  f4 += g_t1da.mips[mipSlice][pos3];  /* expected-error {{no viable overloaded operator[] for type 'Texture1DArray<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'vector<[...], 3>' to 'vector<[...], 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
+  f4 += g_t1da.mips[mipSlice][pos4];  /* expected-error {{no viable overloaded operator[] for type 'Texture1DArray<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'vector<[...], 4>' to 'vector<[...], 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
   f4 += g_t2d.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture2D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint' to 'vector<uint, 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
   f4 += g_t2d.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture2D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint' to 'vector<uint, 2>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
   f4 += g_t2d.mips[mipSlice][pos2];
   f4 += g_t2d.mips[mipSlice][pos2];
@@ -337,10 +504,10 @@ float4 test_mips_double_indexing()
       `-CXXOperatorCallExpr <col:9, col:34> 'const vector<float, 4>' lvalue
       `-CXXOperatorCallExpr <col:9, col:34> 'const vector<float, 4>' lvalue
         |-ImplicitCastExpr <col:29, col:34> 'const vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
         |-ImplicitCastExpr <col:29, col:34> 'const vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
         | `-DeclRefExpr <col:29, col:34> 'const vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 2>) const'
         | `-DeclRefExpr <col:29, col:34> 'const vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 2>) const'
-        |-ImplicitCastExpr <col:9, col:28> 'const Texture2D<vector<float, 4> >::mips_slice_type' xvalue <NoOp>
-        | `-CXXOperatorCallExpr <col:9, col:28> 'Texture2D<vector<float, 4> >::mips_slice_type' xvalue
-        |   |-ImplicitCastExpr <col:19, col:28> 'Texture2D<vector<float, 4> >::mips_slice_type &&(*)(unsigned int) const' <FunctionToPointerDecay>
-        |   | `-DeclRefExpr <col:19, col:28> 'Texture2D<vector<float, 4> >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2D<vector<float, 4> >::mips_slice_type &&(unsigned int) const'
+        |-ImplicitCastExpr <col:9, col:28> 'const Texture2D<vector<float, 4> >::mips_slice_type' lvalue <NoOp>
+        | `-CXXOperatorCallExpr <col:9, col:28> 'Texture2D<vector<float, 4> >::mips_slice_type' lvalue
+        |   |-ImplicitCastExpr <col:19, col:28> 'Texture2D<vector<float, 4> >::mips_slice_type &(*)(unsigned int) const' <FunctionToPointerDecay>
+        |   | `-DeclRefExpr <col:19, col:28> 'Texture2D<vector<float, 4> >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2D<vector<float, 4> >::mips_slice_type &(unsigned int) const'
         |   |-ImplicitCastExpr <col:9, col:15> 'const Texture2D<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   |-ImplicitCastExpr <col:9, col:15> 'const Texture2D<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   | `-MemberExpr <col:9, col:15> 'Texture2D<vector<float, 4> >::mips_type' lvalue .mips
         |   | `-MemberExpr <col:9, col:15> 'Texture2D<vector<float, 4> >::mips_type' lvalue .mips
         |   |   `-DeclRefExpr <col:9> 'Texture2D':'Texture2D<vector<float, 4> >' lvalue Var 'g_t2d' 'Texture2D':'Texture2D<vector<float, 4> >'
         |   |   `-DeclRefExpr <col:9> 'Texture2D':'Texture2D<vector<float, 4> >' lvalue Var 'g_t2d' 'Texture2D':'Texture2D<vector<float, 4> >'
@@ -351,6 +518,7 @@ float4 test_mips_double_indexing()
   */
   */
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
   f4 += g_t2da.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture2DArray<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
   f4 += g_t2da.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture2DArray<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
+  f4 += g_t2da.mips[mipSlice][pos2];  /* expected-error {{no viable overloaded operator[] for type 'Texture2DArray<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'vector<[...], 2>' to 'vector<[...], 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
   f4 += g_t2da.mips[mipSlice][pos3];
   f4 += g_t2da.mips[mipSlice][pos3];
   /*verify-ast
   /*verify-ast
     CompoundAssignOperator <col:3, col:35> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
     CompoundAssignOperator <col:3, col:35> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
@@ -359,10 +527,10 @@ float4 test_mips_double_indexing()
       `-CXXOperatorCallExpr <col:9, col:35> 'const vector<float, 4>' lvalue
       `-CXXOperatorCallExpr <col:9, col:35> 'const vector<float, 4>' lvalue
         |-ImplicitCastExpr <col:30, col:35> 'const vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
         |-ImplicitCastExpr <col:30, col:35> 'const vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
         | `-DeclRefExpr <col:30, col:35> 'const vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 3>) const'
         | `-DeclRefExpr <col:30, col:35> 'const vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 3>) const'
-        |-ImplicitCastExpr <col:9, col:29> 'const Texture2DArray<vector<float, 4> >::mips_slice_type' xvalue <NoOp>
-        | `-CXXOperatorCallExpr <col:9, col:29> 'Texture2DArray<vector<float, 4> >::mips_slice_type' xvalue
-        |   |-ImplicitCastExpr <col:20, col:29> 'Texture2DArray<vector<float, 4> >::mips_slice_type &&(*)(unsigned int) const' <FunctionToPointerDecay>
-        |   | `-DeclRefExpr <col:20, col:29> 'Texture2DArray<vector<float, 4> >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DArray<vector<float, 4> >::mips_slice_type &&(unsigned int) const'
+        |-ImplicitCastExpr <col:9, col:29> 'const Texture2DArray<vector<float, 4> >::mips_slice_type' lvalue <NoOp>
+        | `-CXXOperatorCallExpr <col:9, col:29> 'Texture2DArray<vector<float, 4> >::mips_slice_type' lvalue
+        |   |-ImplicitCastExpr <col:20, col:29> 'Texture2DArray<vector<float, 4> >::mips_slice_type &(*)(unsigned int) const' <FunctionToPointerDecay>
+        |   | `-DeclRefExpr <col:20, col:29> 'Texture2DArray<vector<float, 4> >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DArray<vector<float, 4> >::mips_slice_type &(unsigned int) const'
         |   |-ImplicitCastExpr <col:9, col:16> 'const Texture2DArray<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   |-ImplicitCastExpr <col:9, col:16> 'const Texture2DArray<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   | `-MemberExpr <col:9, col:16> 'Texture2DArray<vector<float, 4> >::mips_type' lvalue .mips
         |   | `-MemberExpr <col:9, col:16> 'Texture2DArray<vector<float, 4> >::mips_type' lvalue .mips
         |   |   `-DeclRefExpr <col:9> 'Texture2DArray':'Texture2DArray<vector<float, 4> >' lvalue Var 'g_t2da' 'Texture2DArray':'Texture2DArray<vector<float, 4> >'
         |   |   `-DeclRefExpr <col:9> 'Texture2DArray':'Texture2DArray<vector<float, 4> >' lvalue Var 'g_t2da' 'Texture2DArray':'Texture2DArray<vector<float, 4> >'
@@ -371,12 +539,14 @@ float4 test_mips_double_indexing()
         `-ImplicitCastExpr <col:31> 'uint3':'vector<unsigned int, 3>' <LValueToRValue>
         `-ImplicitCastExpr <col:31> 'uint3':'vector<unsigned int, 3>' <LValueToRValue>
           `-DeclRefExpr <col:31> 'uint3':'vector<unsigned int, 3>' lvalue Var 'pos3' 'uint3':'vector<unsigned int, 3>'
           `-DeclRefExpr <col:31> 'uint3':'vector<unsigned int, 3>' lvalue Var 'pos3' 'uint3':'vector<unsigned int, 3>'
   */
   */
+  f4 += g_t2da.mips[mipSlice][pos4];  /* expected-error {{no viable overloaded operator[] for type 'Texture2DArray<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'vector<[...], 4>' to 'vector<[...], 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}} */
   // fxc error X3018: invalid subscript 'mips'
   // fxc error X3018: invalid subscript 'mips'
   f4 += g_t2dms.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Texture2DMS<vector<float, 4>, 8>'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_t2dms.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Texture2DMS<vector<float, 4>, 8>'}} fxc-error {{X3018: invalid subscript 'mips'}}
   // fxc error X3018: invalid subscript 'mips'
   // fxc error X3018: invalid subscript 'mips'
   f4 += g_t2dmsa.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Texture2DMSArray<vector<float, 4>, 8>'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_t2dmsa.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Texture2DMSArray<vector<float, 4>, 8>'}} fxc-error {{X3018: invalid subscript 'mips'}}
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
   // fxc error X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions
   f4 += g_t3d.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture3D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
   f4 += g_t3d.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture3D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'uint' to 'vector<uint, 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
+  f4 += g_t3d.mips[mipSlice][pos2]; // expected-error {{no viable overloaded operator[] for type 'Texture3D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'vector<[...], 2>' to 'vector<[...], 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
   f4 += g_t3d.mips[mipSlice][pos3];
   f4 += g_t3d.mips[mipSlice][pos3];
   /*verify-ast
   /*verify-ast
     CompoundAssignOperator <col:3, col:34> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
     CompoundAssignOperator <col:3, col:34> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
@@ -385,10 +555,10 @@ float4 test_mips_double_indexing()
       `-CXXOperatorCallExpr <col:9, col:34> 'const vector<float, 4>' lvalue
       `-CXXOperatorCallExpr <col:9, col:34> 'const vector<float, 4>' lvalue
         |-ImplicitCastExpr <col:29, col:34> 'const vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
         |-ImplicitCastExpr <col:29, col:34> 'const vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
         | `-DeclRefExpr <col:29, col:34> 'const vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 3>) const'
         | `-DeclRefExpr <col:29, col:34> 'const vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 3>) const'
-        |-ImplicitCastExpr <col:9, col:28> 'const Texture3D<vector<float, 4> >::mips_slice_type' xvalue <NoOp>
-        | `-CXXOperatorCallExpr <col:9, col:28> 'Texture3D<vector<float, 4> >::mips_slice_type' xvalue
-        |   |-ImplicitCastExpr <col:19, col:28> 'Texture3D<vector<float, 4> >::mips_slice_type &&(*)(unsigned int) const' <FunctionToPointerDecay>
-        |   | `-DeclRefExpr <col:19, col:28> 'Texture3D<vector<float, 4> >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture3D<vector<float, 4> >::mips_slice_type &&(unsigned int) const'
+        |-ImplicitCastExpr <col:9, col:28> 'const Texture3D<vector<float, 4> >::mips_slice_type' lvalue <NoOp>
+        | `-CXXOperatorCallExpr <col:9, col:28> 'Texture3D<vector<float, 4> >::mips_slice_type' lvalue
+        |   |-ImplicitCastExpr <col:19, col:28> 'Texture3D<vector<float, 4> >::mips_slice_type &(*)(unsigned int) const' <FunctionToPointerDecay>
+        |   | `-DeclRefExpr <col:19, col:28> 'Texture3D<vector<float, 4> >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture3D<vector<float, 4> >::mips_slice_type &(unsigned int) const'
         |   |-ImplicitCastExpr <col:9, col:15> 'const Texture3D<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   |-ImplicitCastExpr <col:9, col:15> 'const Texture3D<vector<float, 4> >::mips_type' lvalue <NoOp>
         |   | `-MemberExpr <col:9, col:15> 'Texture3D<vector<float, 4> >::mips_type' lvalue .mips
         |   | `-MemberExpr <col:9, col:15> 'Texture3D<vector<float, 4> >::mips_type' lvalue .mips
         |   |   `-DeclRefExpr <col:9> 'Texture3D':'Texture3D<vector<float, 4> >' lvalue Var 'g_t3d' 'Texture3D':'Texture3D<vector<float, 4> >'
         |   |   `-DeclRefExpr <col:9> 'Texture3D':'Texture3D<vector<float, 4> >' lvalue Var 'g_t3d' 'Texture3D':'Texture3D<vector<float, 4> >'
@@ -397,10 +567,18 @@ float4 test_mips_double_indexing()
         `-ImplicitCastExpr <col:30> 'uint3':'vector<unsigned int, 3>' <LValueToRValue>
         `-ImplicitCastExpr <col:30> 'uint3':'vector<unsigned int, 3>' <LValueToRValue>
           `-DeclRefExpr <col:30> 'uint3':'vector<unsigned int, 3>' lvalue Var 'pos3' 'uint3':'vector<unsigned int, 3>'
           `-DeclRefExpr <col:30> 'uint3':'vector<unsigned int, 3>' lvalue Var 'pos3' 'uint3':'vector<unsigned int, 3>'
   */
   */
+  f4 += g_t3d.mips[mipSlice][pos4]; // expected-error {{no viable overloaded operator[] for type 'Texture3D<vector<float, 4> >::mips_slice_type'}} expected-note {{candidate function [with element = const vector<float, 4> &] not viable: no known conversion from 'vector<[...], 4>' to 'vector<[...], 3>' for 1st argument}} fxc-error {{X3120: invalid type for index - index must be a scalar, or a vector with the correct number of dimensions}}
   // fxc error X3018: invalid subscript 'mips'
   // fxc error X3018: invalid subscript 'mips'
   f4 += g_tc.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'TextureCube<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_tc.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'TextureCube<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   // fxc error X3018: invalid subscript 'mips'
   // fxc error X3018: invalid subscript 'mips'
   f4 += g_tca.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'TextureCubeArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
   f4 += g_tca.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'TextureCubeArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'mips'}}
+
+  g_t1d.mips[mipSlice][pos] = f4;       /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t1da.mips[mipSlice][pos2] = f4;     /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t2d.mips[mipSlice][pos2] = f4;      /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t2da.mips[mipSlice][pos3] = f4;     /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t3d.mips[mipSlice][pos3] = f4;      /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+
   return f4;
   return f4;
 }
 }
 
 
@@ -431,6 +609,10 @@ float4 test_sample_indexing()
   f4 += g_tc.sample[offset]; // expected-error {{no member named 'sample' in 'TextureCube<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'sample'}}
   f4 += g_tc.sample[offset]; // expected-error {{no member named 'sample' in 'TextureCube<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'sample'}}
   // fxc error X3018: invalid subscript 'sample'
   // fxc error X3018: invalid subscript 'sample'
   f4 += g_tca.sample[offset]; // expected-error {{no member named 'sample' in 'TextureCubeArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'sample'}}
   f4 += g_tca.sample[offset]; // expected-error {{no member named 'sample' in 'TextureCubeArray<vector<float, 4> >'}} fxc-error {{X3018: invalid subscript 'sample'}}
+
+  g_t2dms.sample[offset] = f4;      /* expected-error {{cannot convert from 'float4' to 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */
+  g_t2dmsa.sample[offset] = f4;     /* expected-error {{cannot convert from 'float4' to 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */
+
   return f4;
   return f4;
 }
 }
 
 
@@ -452,10 +634,10 @@ float4 test_sample_double_indexing()
       `-CXXOperatorCallExpr <col:9, col:41> 'const vector<float, 4>' lvalue
       `-CXXOperatorCallExpr <col:9, col:41> 'const vector<float, 4>' lvalue
         |-ImplicitCastExpr <col:36, col:41> 'const vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
         |-ImplicitCastExpr <col:36, col:41> 'const vector<float, 4> &(*)(vector<uint, 2>) const' <FunctionToPointerDecay>
         | `-DeclRefExpr <col:36, col:41> 'const vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 2>) const'
         | `-DeclRefExpr <col:36, col:41> 'const vector<float, 4> &(vector<uint, 2>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 2>) const'
-        |-ImplicitCastExpr <col:9, col:35> 'const Texture2DMS<vector<float, 4>, 8>::sample_slice_type' xvalue <NoOp>
-        | `-CXXOperatorCallExpr <col:9, col:35> 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type' xvalue
-        |   |-ImplicitCastExpr <col:23, col:35> 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type &&(*)(unsigned int) const' <FunctionToPointerDecay>
-        |   | `-DeclRefExpr <col:23, col:35> 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type &&(unsigned int) const'
+        |-ImplicitCastExpr <col:9, col:35> 'const Texture2DMS<vector<float, 4>, 8>::sample_slice_type' lvalue <NoOp>
+        | `-CXXOperatorCallExpr <col:9, col:35> 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type' lvalue
+        |   |-ImplicitCastExpr <col:23, col:35> 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type &(*)(unsigned int) const' <FunctionToPointerDecay>
+        |   | `-DeclRefExpr <col:23, col:35> 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMS<vector<float, 4>, 8>::sample_slice_type &(unsigned int) const'
         |   |-ImplicitCastExpr <col:9, col:17> 'const Texture2DMS<vector<float, 4>, 8>::sample_type' lvalue <NoOp>
         |   |-ImplicitCastExpr <col:9, col:17> 'const Texture2DMS<vector<float, 4>, 8>::sample_type' lvalue <NoOp>
         |   | `-MemberExpr <col:9, col:17> 'Texture2DMS<vector<float, 4>, 8>::sample_type' lvalue .sample
         |   | `-MemberExpr <col:9, col:17> 'Texture2DMS<vector<float, 4>, 8>::sample_type' lvalue .sample
         |   |   `-DeclRefExpr <col:9> 'Texture2DMS<float4, 8>':'Texture2DMS<vector<float, 4>, 8>' lvalue Var 'g_t2dms' 'Texture2DMS<float4, 8>':'Texture2DMS<vector<float, 4>, 8>'
         |   |   `-DeclRefExpr <col:9> 'Texture2DMS<float4, 8>':'Texture2DMS<vector<float, 4>, 8>' lvalue Var 'g_t2dms' 'Texture2DMS<float4, 8>':'Texture2DMS<vector<float, 4>, 8>'
@@ -474,10 +656,10 @@ float4 test_sample_double_indexing()
       `-CXXOperatorCallExpr <col:9, col:42> 'const vector<float, 4>' lvalue
       `-CXXOperatorCallExpr <col:9, col:42> 'const vector<float, 4>' lvalue
         |-ImplicitCastExpr <col:37, col:42> 'const vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
         |-ImplicitCastExpr <col:37, col:42> 'const vector<float, 4> &(*)(vector<uint, 3>) const' <FunctionToPointerDecay>
         | `-DeclRefExpr <col:37, col:42> 'const vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 3>) const'
         | `-DeclRefExpr <col:37, col:42> 'const vector<float, 4> &(vector<uint, 3>) const' lvalue CXXMethod 'operator[]' 'const vector<float, 4> &(vector<uint, 3>) const'
-        |-ImplicitCastExpr <col:9, col:36> 'const Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type' xvalue <NoOp>
-        | `-CXXOperatorCallExpr <col:9, col:36> 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type' xvalue
-        |   |-ImplicitCastExpr <col:24, col:36> 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type &&(*)(unsigned int) const' <FunctionToPointerDecay>
-        |   | `-DeclRefExpr <col:24, col:36> 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type &&(unsigned int) const'
+        |-ImplicitCastExpr <col:9, col:36> 'const Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type' lvalue <NoOp>
+        | `-CXXOperatorCallExpr <col:9, col:36> 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type' lvalue
+        |   |-ImplicitCastExpr <col:24, col:36> 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type &(*)(unsigned int) const' <FunctionToPointerDecay>
+        |   | `-DeclRefExpr <col:24, col:36> 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMSArray<vector<float, 4>, 8>::sample_slice_type &(unsigned int) const'
         |   |-ImplicitCastExpr <col:9, col:18> 'const Texture2DMSArray<vector<float, 4>, 8>::sample_type' lvalue <NoOp>
         |   |-ImplicitCastExpr <col:9, col:18> 'const Texture2DMSArray<vector<float, 4>, 8>::sample_type' lvalue <NoOp>
         |   | `-MemberExpr <col:9, col:18> 'Texture2DMSArray<vector<float, 4>, 8>::sample_type' lvalue .sample
         |   | `-MemberExpr <col:9, col:18> 'Texture2DMSArray<vector<float, 4>, 8>::sample_type' lvalue .sample
         |   |   `-DeclRefExpr <col:9> 'Texture2DMSArray<float4, 8>':'Texture2DMSArray<vector<float, 4>, 8>' lvalue Var 'g_t2dmsa' 'Texture2DMSArray<float4, 8>':'Texture2DMSArray<vector<float, 4>, 8>'
         |   |   `-DeclRefExpr <col:9> 'Texture2DMSArray<float4, 8>':'Texture2DMSArray<vector<float, 4>, 8>' lvalue Var 'g_t2dmsa' 'Texture2DMSArray<float4, 8>':'Texture2DMSArray<vector<float, 4>, 8>'
@@ -486,6 +668,10 @@ float4 test_sample_double_indexing()
         `-ImplicitCastExpr <col:38> 'uint3':'vector<unsigned int, 3>' <LValueToRValue>
         `-ImplicitCastExpr <col:38> 'uint3':'vector<unsigned int, 3>' <LValueToRValue>
           `-DeclRefExpr <col:38> 'uint3':'vector<unsigned int, 3>' lvalue Var 'pos3' 'uint3':'vector<unsigned int, 3>'
           `-DeclRefExpr <col:38> 'uint3':'vector<unsigned int, 3>' lvalue Var 'pos3' 'uint3':'vector<unsigned int, 3>'
   */
   */
+
+  g_t2dms.sample[sampleSlice][pos2] = f4;  /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+  g_t2dmsa.sample[sampleSlice][pos3] = f4; /* expected-error {{cannot assign to return value because function 'operator[]<const vector<float, 4> &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */
+
   return f4;
   return f4;
 }
 }
 
 

+ 1 - 1
tools/clang/test/HLSLFileCheck/validation/rawbufferstore_uav.hlsl

@@ -1,6 +1,6 @@
 // RUN: %dxilver 1.5 | %dxc -T vs_6_2 -E main %s | FileCheck %s
 // RUN: %dxilver 1.5 | %dxc -T vs_6_2 -E main %s | FileCheck %s
 
 
-// CHECK: store should be on uav resource
+// CHECK: error: cannot assign to return value because function 'operator[]<const int &>' returns a const value
 
 
 StructuredBuffer<int> buf;
 StructuredBuffer<int> buf;
 void main() { buf[0] = 0; }
 void main() { buf[0] = 0; }

+ 14 - 4
utils/hct/VerifierHelper.py

@@ -48,13 +48,18 @@ HlslVerifierTestCpp = os.path.expandvars(r'${HLSL_SRC_DIR}\tools\clang\unittests
 HlslDataDir = os.path.expandvars(r'${HLSL_SRC_DIR}\tools\clang\test\HLSL')
 HlslDataDir = os.path.expandvars(r'${HLSL_SRC_DIR}\tools\clang\test\HLSL')
 HlslBinDir = os.path.expandvars(r'${HLSL_BLD_DIR}\Debug\bin')
 HlslBinDir = os.path.expandvars(r'${HLSL_BLD_DIR}\Debug\bin')
 VerifierTests = {
 VerifierTests = {
+    'RunArrayIndexOutOfBounds': 'array-index-out-of-bounds-HV-2016.hlsl',
+    'RunArrayLength': 'array-length.hlsl',
     'RunAttributes': 'attributes.hlsl',
     'RunAttributes': 'attributes.hlsl',
     'RunBadInclude': 'bad-include.hlsl',
     'RunBadInclude': 'bad-include.hlsl',
     'RunBinopDims': 'binop-dims.hlsl',
     'RunBinopDims': 'binop-dims.hlsl',
+    'RunBuiltinTypesNoInheritance': 'builtin-types-no-inheritance.hlsl',
     'RunCXX11Attributes': 'cxx11-attributes.hlsl',
     'RunCXX11Attributes': 'cxx11-attributes.hlsl',
     'RunConstAssign': 'const-assign.hlsl',
     'RunConstAssign': 'const-assign.hlsl',
     'RunConstDefault': 'const-default.hlsl',
     'RunConstDefault': 'const-default.hlsl',
     'RunConstExpr': 'const-expr.hlsl',
     'RunConstExpr': 'const-expr.hlsl',
+    'RunConversionsBetweenTypeShapes': 'conversions-between-type-shapes.hlsl',
+    'RunConversionsNonNumericAggregates': 'conversions-non-numeric-aggregates.hlsl',
     'RunCppErrors': 'cpp-errors.hlsl',
     'RunCppErrors': 'cpp-errors.hlsl',
     'RunCppErrorsHV2015': 'cpp-errors-hv2015.hlsl',
     'RunCppErrorsHV2015': 'cpp-errors-hv2015.hlsl',
     'RunDerivedToBaseCasts': 'derived-to-base.hlsl',
     'RunDerivedToBaseCasts': 'derived-to-base.hlsl',
@@ -62,12 +67,15 @@ VerifierTests = {
     'RunEnums': 'enums.hlsl',
     'RunEnums': 'enums.hlsl',
     'RunFunctions': 'functions.hlsl',
     'RunFunctions': 'functions.hlsl',
     'RunImplicitCasts': 'implicit-casts.hlsl',
     'RunImplicitCasts': 'implicit-casts.hlsl',
+    'RunIncompleteArray': 'incomp_array_err.hlsl',
+    'RunIncompleteType': 'incomplete-type.hlsl',
     'RunIndexingOperator': 'indexing-operator.hlsl',
     'RunIndexingOperator': 'indexing-operator.hlsl',
     'RunIntrinsicExamples': 'intrinsic-examples.hlsl',
     'RunIntrinsicExamples': 'intrinsic-examples.hlsl',
     'RunLiterals': 'literals.hlsl',
     'RunLiterals': 'literals.hlsl',
     'RunMatrixAssignments': 'matrix-assignments.hlsl',
     'RunMatrixAssignments': 'matrix-assignments.hlsl',
     'RunMatrixSyntax': 'matrix-syntax.hlsl',
     'RunMatrixSyntax': 'matrix-syntax.hlsl',
     'RunMatrixSyntaxExactPrecision': 'matrix-syntax-exact-precision.hlsl',
     'RunMatrixSyntaxExactPrecision': 'matrix-syntax-exact-precision.hlsl',
+    'RunMintypesPromotionWarnings': 'mintypes-promotion-warnings.hlsl',
     'RunMoreOperators': 'more-operators.hlsl',
     'RunMoreOperators': 'more-operators.hlsl',
     'RunObjectOperators': 'object-operators.hlsl',
     'RunObjectOperators': 'object-operators.hlsl',
     'RunPackReg': 'packreg.hlsl',
     'RunPackReg': 'packreg.hlsl',
@@ -79,6 +87,7 @@ VerifierTests = {
     'RunScalarOperatorsAssignExactPrecision': 'scalar-operators-assign-exact-precision.hlsl',
     'RunScalarOperatorsAssignExactPrecision': 'scalar-operators-assign-exact-precision.hlsl',
     'RunScalarOperatorsExactPrecision': 'scalar-operators-exact-precision.hlsl',
     'RunScalarOperatorsExactPrecision': 'scalar-operators-exact-precision.hlsl',
     'RunSemantics': 'semantics.hlsl',
     'RunSemantics': 'semantics.hlsl',
+    'RunSizeof': 'sizeof.hlsl',
     'RunString': 'string.hlsl',
     'RunString': 'string.hlsl',
     'RunStructAssignments': 'struct-assignments.hlsl',
     'RunStructAssignments': 'struct-assignments.hlsl',
     'RunSubobjects': 'subobjects-syntax.hlsl',
     'RunSubobjects': 'subobjects-syntax.hlsl',
@@ -100,6 +109,7 @@ fxcExcludedTests = [
     'RunCppErrorsHV2015',
     'RunCppErrorsHV2015',
     'RunCXX11Attributes',
     'RunCXX11Attributes',
     'RunEnums',
     'RunEnums',
+    'RunIncompleteType',
     'RunIntrinsicExamples',
     'RunIntrinsicExamples',
     'RunMatrixSyntaxExactPrecision',
     'RunMatrixSyntaxExactPrecision',
     'RunRayTracings',
     'RunRayTracings',
@@ -578,7 +588,7 @@ class File(object):
             result[i] = line, diag_col, expected
             result[i] = line, diag_col, expected
 
 
         with open(result_filename, 'wt') as f:
         with open(result_filename, 'wt') as f:
-            f.write('\n'.join(map(lambda (line, diag_col, expected): line, result)))
+            f.write('\n'.join(map((lambda res: res[0]), result)))
 
 
     def TryAst(self, result_filename=None):
     def TryAst(self, result_filename=None):
         temp_filename = os.path.expandvars(r'${TEMP}\%s' % os.path.split(self.filename)[1])
         temp_filename = os.path.expandvars(r'${TEMP}\%s' % os.path.split(self.filename)[1])
@@ -658,19 +668,19 @@ def ProcessVerifierOutput(lines):
             files[cur_filename] = File(cur_filename)
             files[cur_filename] = File(cur_filename)
             state = 'WaitingForCategory'
             state = 'WaitingForCategory'
             continue
             continue
-        if state is 'WaitingForFile':
+        if state == 'WaitingForFile':
             m = rxEndGroup.match(line)
             m = rxEndGroup.match(line)
             if m and m.group(2) == 'Failed':
             if m and m.group(2) == 'Failed':
                 # This usually happens when compiler crashes
                 # This usually happens when compiler crashes
                 print('Fatal Error: test %s failed without verifier results.' % cur_test)
                 print('Fatal Error: test %s failed without verifier results.' % cur_test)
-        if state is 'WaitingForCategory' or state is 'ReadingErrors':
+        if state == 'WaitingForCategory' or state == 'ReadingErrors':
             m = rxExpected.match(line)
             m = rxExpected.match(line)
             if m:
             if m:
                 ew = m.group(1)
                 ew = m.group(1)
                 expected = m.group(2) == 'expected but not seen'
                 expected = m.group(2) == 'expected but not seen'
                 state = 'ReadingErrors'
                 state = 'ReadingErrors'
                 continue
                 continue
-        if state is 'ReadingErrors':
+        if state == 'ReadingErrors':
             m = rxDiagReport.match(line)
             m = rxDiagReport.match(line)
             if m:
             if m:
                 line_num = int(m.group(2))
                 line_num = int(m.group(2))