From de00b014ac3554bea9c8d3b440c8fae7b531f42c Mon Sep 17 00:00:00 2001 From: Tex Riddell Date: Wed, 17 Mar 2021 11:40:48 -0700 Subject: [PATCH] Fix const error check for object subscript operator (#3580) --- tools/clang/lib/Sema/SemaExpr.cpp | 5 +- .../array-index-out-of-bounds-HV-2016.hlsl | 4 +- tools/clang/test/HLSL/attributes.hlsl | 104 ++++---- .../HLSL/builtin-types-no-inheritance.hlsl | 26 +- .../conversions-non-numeric-aggregates.hlsl | 12 +- tools/clang/test/HLSL/incomp_array_err.hlsl | 14 +- tools/clang/test/HLSL/indexing-operator.hlsl | 242 ++++++++++++++++-- .../validation/rawbufferstore_uav.hlsl | 2 +- utils/hct/VerifierHelper.py | 18 +- 9 files changed, 313 insertions(+), 114 deletions(-) diff --git a/tools/clang/lib/Sema/SemaExpr.cpp b/tools/clang/lib/Sema/SemaExpr.cpp index e49e0312a..09f49e8a5 100644 --- a/tools/clang/lib/Sema/SemaExpr.cpp +++ b/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)); // HLSL Change Starts - check const for array subscript operator for HLSL vector/matrix 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(E); + QualType qt = expr->getArg(0)->getType(); + if ((hlsl::IsMatrixType(&S, qt) || hlsl::IsVectorType(&S, qt))) return HLSLCheckForModifiableLValue(E, Loc, S); } // HLSL Change Ends diff --git a/tools/clang/test/HLSL/array-index-out-of-bounds-HV-2016.hlsl b/tools/clang/test/HLSL/array-index-out-of-bounds-HV-2016.hlsl index cc5ee986e..2619ec20b 100644 --- a/tools/clang/test/HLSL/array-index-out-of-bounds-HV-2016.hlsl +++ b/tools/clang/test/HLSL/array-index-out-of-bounds-HV-2016.hlsl @@ -3,10 +3,10 @@ void dead() { 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[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() {} \ No newline at end of file diff --git a/tools/clang/test/HLSL/attributes.hlsl b/tools/clang/test/HLSL/attributes.hlsl index 836dbe130..1fdc10a5a 100644 --- a/tools/clang/test/HLSL/attributes.hlsl +++ b/tools/clang/test/HLSL/attributes.hlsl @@ -20,13 +20,13 @@ int loop_before_return() { } 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; return 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) { case 0: return 1; @@ -36,13 +36,13 @@ int loop_before_switch(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; return 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) { case 0: return 1; @@ -52,13 +52,13 @@ int fastopt_before_switch(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; return 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) { case 0: return 1; @@ -68,13 +68,13 @@ int unroll_before_switch(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; return 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) { case 0: return 1; @@ -85,7 +85,7 @@ int allow_uav_condition_before_switch(int a) { int branch_before_for() { 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++; return result; } @@ -93,7 +93,7 @@ int branch_before_for() { int branch_before_while() { int result = 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) { result++; i++; @@ -104,7 +104,7 @@ int branch_before_while() { int branch_before_do() { int result = 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 { result++; i++; @@ -114,7 +114,7 @@ int branch_before_do() { int flatten_before_for() { 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++; return result; } @@ -122,7 +122,7 @@ int flatten_before_for() { int flatten_before_while() { int result = 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) { result++; i++; @@ -133,7 +133,7 @@ int flatten_before_while() { int flatten_before_do() { int result = 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 { result++; i++; @@ -143,7 +143,7 @@ int flatten_before_do() { int forcecase_before_for() { 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++; return result; } @@ -151,7 +151,7 @@ int forcecase_before_for() { int forcecase_before_while() { int result = 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) { result++; i++; @@ -162,7 +162,7 @@ int forcecase_before_while() { int forcecase_before_do() { int result = 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 { result++; i++; @@ -171,14 +171,14 @@ int forcecase_before_do() { } 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; return a; } int call_before_for() { 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++; return result; } @@ -186,7 +186,7 @@ int call_before_for() { int call_before_while() { int result = 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) { result++; i++; @@ -197,7 +197,7 @@ int call_before_while() { int call_before_do() { int result = 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 { result++; i++; @@ -206,7 +206,7 @@ int call_before_do() { } 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; return a; } @@ -256,9 +256,9 @@ int neg_unroll() { // 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 - AttributedStmt + AttributedStmt |-HLSLUnrollAttr -1 - `-ForStmt + `-ForStmt |-DeclStmt | `-VarDecl col:12 used i 'int' cinit | `-ImplicitCastExpr 'int' @@ -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 [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 - AttributedStmt + AttributedStmt |-HLSLUnrollAttr 0 - `-ForStmt + `-ForStmt |-DeclStmt | `-VarDecl col:12 used i 'int' cinit | `-ImplicitCastExpr 'int' @@ -327,9 +327,9 @@ int uav() { uint i; [allow_uav_condition] /*verify-ast - AttributedStmt + AttributedStmt |-HLSLAllowUAVConditionAttr - `-ForStmt + `-ForStmt |-BinaryOperator 'uint':'unsigned int' '=' | |-DeclRefExpr 'uint':'unsigned int' lvalue Var 'i' 'uint':'unsigned int' | `-ImplicitCastExpr 'uint':'unsigned int' @@ -342,7 +342,7 @@ int uav() { | `-DeclRefExpr 'const uint':'const unsigned int' lvalue Var 'g_dealiasTableSize' 'const uint':'const unsigned int' |-UnaryOperator 'uint':'unsigned int' lvalue prefix '++' | `-DeclRefExpr 'uint':'unsigned int' lvalue Var 'i' 'uint':'unsigned int' - `-CompoundStmt + `-CompoundStmt */ for (i = g_dealiasTableOffset; i < g_dealiasTableSize; ++i) { } @@ -393,16 +393,16 @@ void all_wrong() { } [patchconstantfunc("PatchFoo")] HSFoo HSMain( InputPatch p, /*verify-ast - FunctionDecl line:202:7 HSMain 'HSFoo (InputPatch, uint, uint)' + FunctionDecl line:394:7 HSMain 'HSFoo (InputPatch, uint, uint)' |-ParmVarDecl col:37 used p 'InputPatch':'InputPatch' - |-ParmVarDecl col:20 used i 'uint':'unsigned int' + |-ParmVarDecl col:20 used i 'uint':'unsigned int' | `-SemanticDecl "SV_OutputControlPointID" - |-ParmVarDecl col:20 used PatchID 'uint':'unsigned int' + |-ParmVarDecl col:20 used PatchID 'uint':'unsigned int' | `-SemanticDecl "SV_PrimitiveID" - |-CompoundStmt - | |-DeclStmt + |-CompoundStmt + | |-DeclStmt | | `-VarDecl col:11 used output 'HSFoo' nrvo - | |-DeclStmt + | |-DeclStmt | | `-VarDecl col:12 used r 'float4':'vector' cinit | | `-CXXFunctionalCastExpr 'float4':'vector' functional cast to float4 | | `-InitListExpr 'float4':'vector' @@ -417,7 +417,7 @@ HSFoo HSMain( InputPatch p, | | | `-DeclRefExpr 'uint':'unsigned int' lvalue ParmVar 'PatchID' 'uint':'unsigned int' | | `-ImplicitCastExpr 'float' | | `-IntegerLiteral 'literal int' 1 - | |-CompoundAssignOperator 'float4':'vector' lvalue '+=' ComputeLHSTy='float4':'vector' ComputeResultTy='float4':'vector' + | |-CompoundAssignOperator 'float4':'vector' lvalue '+=' ComputeLHSTy='float4':'vector' ComputeResultTy='float4':'vector' | | |-DeclRefExpr 'float4':'vector' lvalue Var 'r' 'float4':'vector' | | `-CXXMemberCallExpr 'vector' | | |-MemberExpr '' .Load @@ -432,7 +432,7 @@ HSFoo HSMain( InputPatch p, | | `-ImplicitCastExpr 'vector':'vector' | | `-HLSLVectorElementExpr 'vector':'vector' lvalue vectorcomponent xyz | | `-DeclRefExpr 'float4':'vector' lvalue Var 'r' 'float4':'vector' - | |-BinaryOperator 'float3':'vector' '=' + | |-BinaryOperator 'float3':'vector' '=' | | |-MemberExpr 'float3':'vector' lvalue .pos | | | `-DeclRefExpr 'HSFoo' lvalue Var 'output' 'HSFoo' | | `-BinaryOperator 'float3':'vector' '+' @@ -448,14 +448,14 @@ HSFoo HSMain( InputPatch p, | | `-ImplicitCastExpr 'vector':'vector' | | `-HLSLVectorElementExpr 'vector':'vector' lvalue vectorcomponent xyz | | `-DeclRefExpr 'float4':'vector' lvalue Var 'r' 'float4':'vector' - | `-ReturnStmt + | `-ReturnStmt | `-ImplicitCastExpr 'HSFoo' | `-DeclRefExpr 'HSFoo' lvalue Var 'output' 'HSFoo' - |-HLSLPatchConstantFuncAttr "PatchFoo" - |-HLSLOutputControlPointsAttr 16 - |-HLSLOutputTopologyAttr "triangle_cw" - |-HLSLPartitioningAttr "integer" - `-HLSLDomainAttr "quad" + |-HLSLPatchConstantFuncAttr "PatchFoo" + |-HLSLOutputControlPointsAttr 16 + |-HLSLOutputTopologyAttr "triangle_cw" + |-HLSLPartitioningAttr "integer" + `-HLSLDomainAttr "quad" */ uint i : SV_OutputControlPointID, uint PatchID : SV_PrimitiveID ) @@ -561,13 +561,13 @@ void clipplanes_bad_scalar_swizzle(); [clipplanes( /*verify-ast - HLSLClipPlanesAttr - |-DeclRefExpr 'const float4':'const vector' lvalue Var 'f4' 'const float4':'const vector' - |-ArraySubscriptExpr 'const float4':'const vector' lvalue + HLSLClipPlanesAttr + |-DeclRefExpr 'const float4':'const vector' lvalue Var 'f4' 'const float4':'const vector' + |-ArraySubscriptExpr 'const float4':'const vector' lvalue | |-ImplicitCastExpr 'const float4 [2]' | | `-DeclRefExpr 'const float4 [2]' lvalue Var 'cp4' 'const float4 [2]' | `-IntegerLiteral 'literal int' 0 - |-ArraySubscriptExpr 'float4':'vector' lvalue + |-ArraySubscriptExpr 'float4':'vector' lvalue | |-ImplicitCastExpr 'float4 [5]' | | `-MemberExpr 'float4 const[5]' lvalue .cp5 | | `-DeclRefExpr 'const global_struct' lvalue Var 'gs' 'const global_struct' @@ -585,21 +585,21 @@ float4 clipplanes_good(); [clipplanes( /*verify-ast - HLSLClipPlanesAttr - |-ParenExpr 'const float4':'const vector' lvalue + HLSLClipPlanesAttr + |-ParenExpr 'const float4':'const vector' lvalue | `-DeclRefExpr 'const float4':'const vector' lvalue Var 'f4' 'const float4':'const vector' - |-ArraySubscriptExpr 'const float4':'const vector' lvalue + |-ArraySubscriptExpr 'const float4':'const vector' lvalue | |-ImplicitCastExpr 'const float4 [2]' | | `-DeclRefExpr 'const float4 [2]' lvalue Var 'cp4' 'const float4 [2]' | `-ParenExpr 'literal int' | `-IntegerLiteral 'literal int' 0 - |-ArraySubscriptExpr 'float4':'vector' lvalue + |-ArraySubscriptExpr 'float4':'vector' lvalue | |-ImplicitCastExpr 'float4 [5]' | | `-MemberExpr 'float4 const[5]' lvalue .cp5 | | `-ParenExpr 'const global_struct' lvalue | | `-DeclRefExpr 'const global_struct' lvalue Var 'gs' 'const global_struct' | `-IntegerLiteral 'literal int' 2 - |-ParenExpr 'float4':'vector' lvalue + |-ParenExpr 'float4':'vector' lvalue | `-ArraySubscriptExpr 'float4':'vector' lvalue | |-ImplicitCastExpr 'float4 [5]' | | `-MemberExpr 'float4 const[5]' lvalue .cp5 diff --git a/tools/clang/test/HLSL/builtin-types-no-inheritance.hlsl b/tools/clang/test/HLSL/builtin-types-no-inheritance.hlsl index 3cf43e4ed..5cdd5baaa 100644 --- a/tools/clang/test/HLSL/builtin-types-no-inheritance.hlsl +++ b/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 -struct F2 : float2 {}; // expected-error {{base 'vector' is marked 'final'}} -struct F4x4 : float4x4 {}; // expected-error {{base 'matrix' is marked 'final'}} -struct Tex3D : Texture3D {}; // expected-error {{base 'Texture3D' is marked 'final'}} -struct BABuf : ByteAddressBuffer {}; // expected-error {{base 'ByteAddressBuffer' is marked 'final'}} -struct StructBuf : StructuredBuffer {}; // 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 {}; // 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 {}; // 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 GSTS : TriangleStream {}; // expected-error {{base 'TriangleStream' is marked 'final'}} -struct HSIP : InputPatch {}; // expected-error {{base 'InputPatch' is marked 'final'}} -struct HSOP : OutputPatch {}; // expected-error {{base 'OutputPatch' is marked 'final'}} +struct GSTS : TriangleStream {}; // expected-error {{base 'TriangleStream' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'TriangleStream'}} +struct HSIP : InputPatch {}; // expected-error {{base 'InputPatch' is marked 'final'}} fxc-error {{X3000: syntax error: unexpected token 'InputPatch'}} +struct HSOP : OutputPatch {}; // 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() {} \ No newline at end of file diff --git a/tools/clang/test/HLSL/conversions-non-numeric-aggregates.hlsl b/tools/clang/test/HLSL/conversions-non-numeric-aggregates.hlsl index 78e0f8caf..e7abdb5a7 100644 --- a/tools/clang/test/HLSL/conversions-non-numeric-aggregates.hlsl +++ b/tools/clang/test/HLSL/conversions-non-numeric-aggregates.hlsl @@ -7,13 +7,13 @@ struct ObjStruct { Buffer a; }; 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[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[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]; 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[1]' to 'int'}} */ + (int)os1; /* expected-error {{cannot convert from 'ObjStruct' to 'int'}} fxc-error {{X3017: cannot convert from 'struct ObjStruct' to 'int'}} */ } \ No newline at end of file diff --git a/tools/clang/test/HLSL/incomp_array_err.hlsl b/tools/clang/test/HLSL/incomp_array_err.hlsl index 5798384d3..a4da32fa4 100644 --- a/tools/clang/test/HLSL/incomp_array_err.hlsl +++ b/tools/clang/test/HLSL/incomp_array_err.hlsl @@ -2,28 +2,28 @@ // 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 }; struct foo1 { 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 { - 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; }; class foo3 { 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 { 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}} +}; \ No newline at end of file diff --git a/tools/clang/test/HLSL/indexing-operator.hlsl b/tools/clang/test/HLSL/indexing-operator.hlsl index d4712bdf2..02e456e86 100644 --- a/tools/clang/test/HLSL/indexing-operator.hlsl +++ b/tools/clang/test/HLSL/indexing-operator.hlsl @@ -3,6 +3,25 @@ // To test with the classic compiler, run // %sdxroot%\tools\x86\fxc.exe /T vs_5_1 indexing-operator.hlsl +/* Expected notes with no locations (implicit built-in): + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} + expected-note@? {{function 'operator[] &>' which returns const-qualified type 'const vector &' declared here}} +*/ + Buffer g_b; StructuredBuffer g_sb; 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}} // 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[] &>' 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[] &>' 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[] &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */ + + g_rw_sb[0] = f4; + /*verify-ast + BinaryOperator 'vector' '=' + |-CXXOperatorCallExpr 'vector' lvalue + | |-ImplicitCastExpr 'vector &(*)(unsigned int) const' + | | `-DeclRefExpr 'vector &(unsigned int) const' lvalue CXXMethod 'operator[]' 'vector &(unsigned int) const' + | |-ImplicitCastExpr 'const RWStructuredBuffer >' lvalue + | | `-DeclRefExpr 'RWStructuredBuffer':'RWStructuredBuffer >' lvalue Var 'g_rw_sb' 'RWStructuredBuffer':'RWStructuredBuffer >' + | `-ImplicitCastExpr 'unsigned int' + | `-IntegerLiteral 'literal int' 0 + `-ImplicitCastExpr 'float4':'vector' + `-DeclRefExpr 'float4':'vector' lvalue Var 'f4' 'float4':'vector' + */ + g_rw_b[0] = f4; + /*verify-ast + BinaryOperator 'vector' '=' + |-CXXOperatorCallExpr 'vector' lvalue + | |-ImplicitCastExpr 'vector &(*)(unsigned int) const' + | | `-DeclRefExpr 'vector &(unsigned int) const' lvalue CXXMethod 'operator[]' 'vector &(unsigned int) const' + | |-ImplicitCastExpr 'const RWBuffer >' lvalue + | | `-DeclRefExpr 'RWBuffer':'RWBuffer >' lvalue Var 'g_rw_b' 'RWBuffer':'RWBuffer >' + | `-ImplicitCastExpr 'unsigned int' + | `-IntegerLiteral 'literal int' 0 + `-ImplicitCastExpr 'float4':'vector' + `-DeclRefExpr 'float4':'vector' lvalue Var 'f4' 'float4':'vector' + */ + g_rw_t1d[0] = f4; + /*verify-ast + BinaryOperator 'vector' '=' + |-CXXOperatorCallExpr 'vector' lvalue + | |-ImplicitCastExpr 'vector &(*)(unsigned int) const' + | | `-DeclRefExpr 'vector &(unsigned int) const' lvalue CXXMethod 'operator[]' 'vector &(unsigned int) const' + | |-ImplicitCastExpr 'const RWTexture1D >' lvalue + | | `-DeclRefExpr 'RWTexture1D':'RWTexture1D >' lvalue Var 'g_rw_t1d' 'RWTexture1D':'RWTexture1D >' + | `-ImplicitCastExpr 'unsigned int' + | `-IntegerLiteral 'literal int' 0 + `-ImplicitCastExpr 'float4':'vector' + `-DeclRefExpr 'float4':'vector' lvalue Var 'f4' 'float4':'vector' + */ + g_rw_t1da[0] = f4; /* expected-error {{no viable overloaded operator[] for type 'RWTexture1DArray'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'literal int' to 'vector' 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'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'literal int' to 'vector' 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'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'literal int' to 'vector' 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'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'literal int' to 'vector' 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; } @@ -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}} // 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[] &>' 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[] &>' 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[] &>' 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'}} expected-note {{candidate function [with element = vector &] 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'}} expected-note {{candidate function [with element = vector &] 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'}} expected-note {{candidate function [with element = vector &] 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 'vector' '=' + |-CXXOperatorCallExpr 'vector' lvalue + | |-ImplicitCastExpr 'vector &(*)(vector) const' + | | `-DeclRefExpr 'vector &(vector) const' lvalue CXXMethod 'operator[]' 'vector &(vector) const' + | |-ImplicitCastExpr 'const RWTexture1DArray >' lvalue + | | `-DeclRefExpr 'RWTexture1DArray':'RWTexture1DArray >' lvalue Var 'g_rw_t1da' 'RWTexture1DArray':'RWTexture1DArray >' + | `-ImplicitCastExpr 'vector' + | `-ImplicitCastExpr 'int2':'vector' + | `-DeclRefExpr 'int2':'vector' lvalue Var 'offset' 'int2':'vector' + `-ImplicitCastExpr 'float4':'vector' + `-DeclRefExpr 'float4':'vector' lvalue Var 'f4' 'float4':'vector' + */ + g_rw_t2d[offset] = f4; + /*verify-ast + BinaryOperator 'vector' '=' + |-CXXOperatorCallExpr 'vector' lvalue + | |-ImplicitCastExpr 'vector &(*)(vector) const' + | | `-DeclRefExpr 'vector &(vector) const' lvalue CXXMethod 'operator[]' 'vector &(vector) const' + | |-ImplicitCastExpr 'const RWTexture2D >' lvalue + | | `-DeclRefExpr 'RWTexture2D':'RWTexture2D >' lvalue Var 'g_rw_t2d' 'RWTexture2D':'RWTexture2D >' + | `-ImplicitCastExpr 'vector' + | `-ImplicitCastExpr 'int2':'vector' + | `-DeclRefExpr 'int2':'vector' lvalue Var 'offset' 'int2':'vector' + `-ImplicitCastExpr 'float4':'vector' + `-DeclRefExpr 'float4':'vector' lvalue Var 'f4' 'float4':'vector' + */ + g_rw_t2da[offset] = f4; /* expected-error {{no viable overloaded operator[] for type 'RWTexture2DArray'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'vector' to 'vector' 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'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'vector' to 'vector' 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; } @@ -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}} // 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[] &>' 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[] &>' 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[] &>' 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'}} expected-note {{candidate function [with element = vector &] 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'}} expected-note {{candidate function [with element = vector &] 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'}} expected-note {{candidate function [with element = vector &] 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'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'vector' to 'vector' 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'}} expected-note {{candidate function [with element = vector &] not viable: no known conversion from 'vector' to 'vector' 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 'vector' '=' + |-CXXOperatorCallExpr 'vector' lvalue + | |-ImplicitCastExpr 'vector &(*)(vector) const' + | | `-DeclRefExpr 'vector &(vector) const' lvalue CXXMethod 'operator[]' 'vector &(vector) const' + | |-ImplicitCastExpr 'const RWTexture2DArray >' lvalue + | | `-DeclRefExpr 'RWTexture2DArray':'RWTexture2DArray >' lvalue Var 'g_rw_t2da' 'RWTexture2DArray':'RWTexture2DArray >' + | `-ImplicitCastExpr 'vector' + | `-ImplicitCastExpr 'int3':'vector' + | `-DeclRefExpr 'int3':'vector' lvalue Var 'offset' 'int3':'vector' + `-ImplicitCastExpr 'float4':'vector' + `-DeclRefExpr 'float4':'vector' lvalue Var 'f4' 'float4':'vector' + */ + g_rw_t3d[offset] = f4; + /*verify-ast + BinaryOperator 'vector' '=' + |-CXXOperatorCallExpr 'vector' lvalue + | |-ImplicitCastExpr 'vector &(*)(vector) const' + | | `-DeclRefExpr 'vector &(vector) const' lvalue CXXMethod 'operator[]' 'vector &(vector) const' + | |-ImplicitCastExpr 'const RWTexture3D >' lvalue + | | `-DeclRefExpr 'RWTexture3D':'RWTexture3D >' lvalue Var 'g_rw_t3d' 'RWTexture3D':'RWTexture3D >' + | `-ImplicitCastExpr 'vector' + | `-ImplicitCastExpr 'int3':'vector' + | `-DeclRefExpr 'int3':'vector' lvalue Var 'offset' 'int3':'vector' + `-ImplicitCastExpr 'float4':'vector' + `-DeclRefExpr 'float4':'vector' lvalue Var 'f4' 'float4':'vector' + */ + return f4; } @@ -270,6 +416,21 @@ float4 test_mips_indexing() f4 += g_tc.mips[offset]; // expected-error {{no member named 'mips' in 'TextureCube >'}} 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 >'}} fxc-error {{X3018: invalid subscript 'mips'}} + + g_t1d.mips[offset] = f4; /* expected-error {{cannot convert from 'float4' to 'Texture1D >::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 >::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 >::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 >::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 >::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 >'}} fxc-error {{X3018: invalid subscript 'mips'}} */ + g_rw_b.mips[offset] = f4; /* expected-error {{no member named 'mips' in 'RWBuffer >'}} fxc-error {{X3018: invalid subscript 'mips'}} */ + g_rw_t1d.mips[offset] = f4; /* expected-error {{no member named 'mips' in 'RWTexture1D >'}} fxc-error {{X3018: invalid subscript 'mips'}} */ + g_rw_t1da.mips[offset] = f4; /* expected-error {{no member named 'mips' in 'RWTexture1DArray >'}} fxc-error {{X3018: invalid subscript 'mips'}} */ + g_rw_t2d.mips[offset] = f4; /* expected-error {{no member named 'mips' in 'RWTexture2D >'}} fxc-error {{X3018: invalid subscript 'mips'}} */ + g_rw_t2da.mips[offset] = f4; /* expected-error {{no member named 'mips' in 'RWTexture2DArray >'}} fxc-error {{X3018: invalid subscript 'mips'}} */ + g_rw_t3d.mips[offset] = f4; /* expected-error {{no member named 'mips' in 'RWTexture3D >'}} fxc-error {{X3018: invalid subscript 'mips'}} */ + return f4; } @@ -280,6 +441,7 @@ float4 test_mips_double_indexing() uint pos = 1; uint2 pos2 = { 1, 2 }; uint3 pos3 = { 1, 2, 3 }; + uint4 pos4 = { 1, 2, 3, 4 }; float4 f4; // fxc error X3018: invalid subscript 'mips' f4 += g_b.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Buffer >'}} fxc-error {{X3018: invalid subscript 'mips'}} @@ -291,10 +453,10 @@ float4 test_mips_double_indexing() `-CXXOperatorCallExpr 'const vector' lvalue |-ImplicitCastExpr 'const vector &(*)(unsigned int) const' | `-DeclRefExpr 'const vector &(unsigned int) const' lvalue CXXMethod 'operator[]' 'const vector &(unsigned int) const' - |-ImplicitCastExpr 'const Texture1D >::mips_slice_type' xvalue - | `-CXXOperatorCallExpr 'Texture1D >::mips_slice_type' xvalue - | |-ImplicitCastExpr 'Texture1D >::mips_slice_type &&(*)(unsigned int) const' - | | `-DeclRefExpr 'Texture1D >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1D >::mips_slice_type &&(unsigned int) const' + |-ImplicitCastExpr 'const Texture1D >::mips_slice_type' lvalue + | `-CXXOperatorCallExpr 'Texture1D >::mips_slice_type' lvalue + | |-ImplicitCastExpr 'Texture1D >::mips_slice_type &(*)(unsigned int) const' + | | `-DeclRefExpr 'Texture1D >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1D >::mips_slice_type &(unsigned int) const' | |-ImplicitCastExpr 'const Texture1D >::mips_type' lvalue | | `-MemberExpr 'Texture1D >::mips_type' lvalue .mips | | `-DeclRefExpr 'Texture1D':'Texture1D >' lvalue Var 'g_t1d' 'Texture1D':'Texture1D >' @@ -303,6 +465,9 @@ float4 test_mips_double_indexing() `-ImplicitCastExpr 'uint':'unsigned int' `-DeclRefExpr 'uint':'unsigned int' lvalue Var 'pos' 'uint':'unsigned int' */ + f4 += g_t1d.mips[mipSlice][pos2]; /* expected-error {{no viable overloaded operator[] for type 'Texture1D >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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 >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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 >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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' f4 += g_sb.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'StructuredBuffer >'}} 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 @@ -315,10 +480,10 @@ float4 test_mips_double_indexing() `-CXXOperatorCallExpr 'const vector' lvalue |-ImplicitCastExpr 'const vector &(*)(vector) const' | `-DeclRefExpr 'const vector &(vector) const' lvalue CXXMethod 'operator[]' 'const vector &(vector) const' - |-ImplicitCastExpr 'const Texture1DArray >::mips_slice_type' xvalue - | `-CXXOperatorCallExpr 'Texture1DArray >::mips_slice_type' xvalue - | |-ImplicitCastExpr 'Texture1DArray >::mips_slice_type &&(*)(unsigned int) const' - | | `-DeclRefExpr 'Texture1DArray >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1DArray >::mips_slice_type &&(unsigned int) const' + |-ImplicitCastExpr 'const Texture1DArray >::mips_slice_type' lvalue + | `-CXXOperatorCallExpr 'Texture1DArray >::mips_slice_type' lvalue + | |-ImplicitCastExpr 'Texture1DArray >::mips_slice_type &(*)(unsigned int) const' + | | `-DeclRefExpr 'Texture1DArray >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture1DArray >::mips_slice_type &(unsigned int) const' | |-ImplicitCastExpr 'const Texture1DArray >::mips_type' lvalue | | `-MemberExpr 'Texture1DArray >::mips_type' lvalue .mips | | `-DeclRefExpr 'Texture1DArray':'Texture1DArray >' lvalue Var 'g_t1da' 'Texture1DArray':'Texture1DArray >' @@ -327,6 +492,8 @@ float4 test_mips_double_indexing() `-ImplicitCastExpr 'uint2':'vector' `-DeclRefExpr 'uint2':'vector' lvalue Var 'pos2' 'uint2':'vector' */ + f4 += g_t1da.mips[mipSlice][pos3]; /* expected-error {{no viable overloaded operator[] for type 'Texture1DArray >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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 >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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 f4 += g_t2d.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture2D >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] not viable: no known conversion from 'uint' to 'vector' 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]; @@ -337,10 +504,10 @@ float4 test_mips_double_indexing() `-CXXOperatorCallExpr 'const vector' lvalue |-ImplicitCastExpr 'const vector &(*)(vector) const' | `-DeclRefExpr 'const vector &(vector) const' lvalue CXXMethod 'operator[]' 'const vector &(vector) const' - |-ImplicitCastExpr 'const Texture2D >::mips_slice_type' xvalue - | `-CXXOperatorCallExpr 'Texture2D >::mips_slice_type' xvalue - | |-ImplicitCastExpr 'Texture2D >::mips_slice_type &&(*)(unsigned int) const' - | | `-DeclRefExpr 'Texture2D >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2D >::mips_slice_type &&(unsigned int) const' + |-ImplicitCastExpr 'const Texture2D >::mips_slice_type' lvalue + | `-CXXOperatorCallExpr 'Texture2D >::mips_slice_type' lvalue + | |-ImplicitCastExpr 'Texture2D >::mips_slice_type &(*)(unsigned int) const' + | | `-DeclRefExpr 'Texture2D >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2D >::mips_slice_type &(unsigned int) const' | |-ImplicitCastExpr 'const Texture2D >::mips_type' lvalue | | `-MemberExpr 'Texture2D >::mips_type' lvalue .mips | | `-DeclRefExpr 'Texture2D':'Texture2D >' lvalue Var 'g_t2d' 'Texture2D':'Texture2D >' @@ -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 f4 += g_t2da.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture2DArray >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] not viable: no known conversion from 'uint' to 'vector' 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 >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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]; /*verify-ast CompoundAssignOperator 'float4':'vector' lvalue '+=' ComputeLHSTy='float4':'vector' ComputeResultTy='float4':'vector' @@ -359,10 +527,10 @@ float4 test_mips_double_indexing() `-CXXOperatorCallExpr 'const vector' lvalue |-ImplicitCastExpr 'const vector &(*)(vector) const' | `-DeclRefExpr 'const vector &(vector) const' lvalue CXXMethod 'operator[]' 'const vector &(vector) const' - |-ImplicitCastExpr 'const Texture2DArray >::mips_slice_type' xvalue - | `-CXXOperatorCallExpr 'Texture2DArray >::mips_slice_type' xvalue - | |-ImplicitCastExpr 'Texture2DArray >::mips_slice_type &&(*)(unsigned int) const' - | | `-DeclRefExpr 'Texture2DArray >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DArray >::mips_slice_type &&(unsigned int) const' + |-ImplicitCastExpr 'const Texture2DArray >::mips_slice_type' lvalue + | `-CXXOperatorCallExpr 'Texture2DArray >::mips_slice_type' lvalue + | |-ImplicitCastExpr 'Texture2DArray >::mips_slice_type &(*)(unsigned int) const' + | | `-DeclRefExpr 'Texture2DArray >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DArray >::mips_slice_type &(unsigned int) const' | |-ImplicitCastExpr 'const Texture2DArray >::mips_type' lvalue | | `-MemberExpr 'Texture2DArray >::mips_type' lvalue .mips | | `-DeclRefExpr 'Texture2DArray':'Texture2DArray >' lvalue Var 'g_t2da' 'Texture2DArray':'Texture2DArray >' @@ -371,12 +539,14 @@ float4 test_mips_double_indexing() `-ImplicitCastExpr 'uint3':'vector' `-DeclRefExpr 'uint3':'vector' lvalue Var 'pos3' 'uint3':'vector' */ + f4 += g_t2da.mips[mipSlice][pos4]; /* expected-error {{no viable overloaded operator[] for type 'Texture2DArray >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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' f4 += g_t2dms.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'Texture2DMS, 8>'}} 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, 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 f4 += g_t3d.mips[mipSlice][pos]; // expected-error {{no viable overloaded operator[] for type 'Texture3D >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] not viable: no known conversion from 'uint' to 'vector' 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 >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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]; /*verify-ast CompoundAssignOperator 'float4':'vector' lvalue '+=' ComputeLHSTy='float4':'vector' ComputeResultTy='float4':'vector' @@ -385,10 +555,10 @@ float4 test_mips_double_indexing() `-CXXOperatorCallExpr 'const vector' lvalue |-ImplicitCastExpr 'const vector &(*)(vector) const' | `-DeclRefExpr 'const vector &(vector) const' lvalue CXXMethod 'operator[]' 'const vector &(vector) const' - |-ImplicitCastExpr 'const Texture3D >::mips_slice_type' xvalue - | `-CXXOperatorCallExpr 'Texture3D >::mips_slice_type' xvalue - | |-ImplicitCastExpr 'Texture3D >::mips_slice_type &&(*)(unsigned int) const' - | | `-DeclRefExpr 'Texture3D >::mips_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture3D >::mips_slice_type &&(unsigned int) const' + |-ImplicitCastExpr 'const Texture3D >::mips_slice_type' lvalue + | `-CXXOperatorCallExpr 'Texture3D >::mips_slice_type' lvalue + | |-ImplicitCastExpr 'Texture3D >::mips_slice_type &(*)(unsigned int) const' + | | `-DeclRefExpr 'Texture3D >::mips_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture3D >::mips_slice_type &(unsigned int) const' | |-ImplicitCastExpr 'const Texture3D >::mips_type' lvalue | | `-MemberExpr 'Texture3D >::mips_type' lvalue .mips | | `-DeclRefExpr 'Texture3D':'Texture3D >' lvalue Var 'g_t3d' 'Texture3D':'Texture3D >' @@ -397,10 +567,18 @@ float4 test_mips_double_indexing() `-ImplicitCastExpr 'uint3':'vector' `-DeclRefExpr 'uint3':'vector' lvalue Var 'pos3' 'uint3':'vector' */ + f4 += g_t3d.mips[mipSlice][pos4]; // expected-error {{no viable overloaded operator[] for type 'Texture3D >::mips_slice_type'}} expected-note {{candidate function [with element = const vector &] 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' f4 += g_tc.mips[mipSlice][pos]; // expected-error {{no member named 'mips' in 'TextureCube >'}} 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 >'}} fxc-error {{X3018: invalid subscript 'mips'}} + + g_t1d.mips[mipSlice][pos] = f4; /* expected-error {{cannot assign to return value because function 'operator[] &>' 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[] &>' 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[] &>' 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[] &>' 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[] &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */ + return f4; } @@ -431,6 +609,10 @@ float4 test_sample_indexing() f4 += g_tc.sample[offset]; // expected-error {{no member named 'sample' in 'TextureCube >'}} 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 >'}} fxc-error {{X3018: invalid subscript 'sample'}} + + g_t2dms.sample[offset] = f4; /* expected-error {{cannot convert from 'float4' to 'Texture2DMS, 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, 8>::sample_slice_type'}} fxc-error {{X3025: global variables are implicitly constant, enable compatibility mode to allow modification}} */ + return f4; } @@ -452,10 +634,10 @@ float4 test_sample_double_indexing() `-CXXOperatorCallExpr 'const vector' lvalue |-ImplicitCastExpr 'const vector &(*)(vector) const' | `-DeclRefExpr 'const vector &(vector) const' lvalue CXXMethod 'operator[]' 'const vector &(vector) const' - |-ImplicitCastExpr 'const Texture2DMS, 8>::sample_slice_type' xvalue - | `-CXXOperatorCallExpr 'Texture2DMS, 8>::sample_slice_type' xvalue - | |-ImplicitCastExpr 'Texture2DMS, 8>::sample_slice_type &&(*)(unsigned int) const' - | | `-DeclRefExpr 'Texture2DMS, 8>::sample_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMS, 8>::sample_slice_type &&(unsigned int) const' + |-ImplicitCastExpr 'const Texture2DMS, 8>::sample_slice_type' lvalue + | `-CXXOperatorCallExpr 'Texture2DMS, 8>::sample_slice_type' lvalue + | |-ImplicitCastExpr 'Texture2DMS, 8>::sample_slice_type &(*)(unsigned int) const' + | | `-DeclRefExpr 'Texture2DMS, 8>::sample_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMS, 8>::sample_slice_type &(unsigned int) const' | |-ImplicitCastExpr 'const Texture2DMS, 8>::sample_type' lvalue | | `-MemberExpr 'Texture2DMS, 8>::sample_type' lvalue .sample | | `-DeclRefExpr 'Texture2DMS':'Texture2DMS, 8>' lvalue Var 'g_t2dms' 'Texture2DMS':'Texture2DMS, 8>' @@ -474,10 +656,10 @@ float4 test_sample_double_indexing() `-CXXOperatorCallExpr 'const vector' lvalue |-ImplicitCastExpr 'const vector &(*)(vector) const' | `-DeclRefExpr 'const vector &(vector) const' lvalue CXXMethod 'operator[]' 'const vector &(vector) const' - |-ImplicitCastExpr 'const Texture2DMSArray, 8>::sample_slice_type' xvalue - | `-CXXOperatorCallExpr 'Texture2DMSArray, 8>::sample_slice_type' xvalue - | |-ImplicitCastExpr 'Texture2DMSArray, 8>::sample_slice_type &&(*)(unsigned int) const' - | | `-DeclRefExpr 'Texture2DMSArray, 8>::sample_slice_type &&(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMSArray, 8>::sample_slice_type &&(unsigned int) const' + |-ImplicitCastExpr 'const Texture2DMSArray, 8>::sample_slice_type' lvalue + | `-CXXOperatorCallExpr 'Texture2DMSArray, 8>::sample_slice_type' lvalue + | |-ImplicitCastExpr 'Texture2DMSArray, 8>::sample_slice_type &(*)(unsigned int) const' + | | `-DeclRefExpr 'Texture2DMSArray, 8>::sample_slice_type &(unsigned int) const' lvalue CXXMethod 'operator[]' 'Texture2DMSArray, 8>::sample_slice_type &(unsigned int) const' | |-ImplicitCastExpr 'const Texture2DMSArray, 8>::sample_type' lvalue | | `-MemberExpr 'Texture2DMSArray, 8>::sample_type' lvalue .sample | | `-DeclRefExpr 'Texture2DMSArray':'Texture2DMSArray, 8>' lvalue Var 'g_t2dmsa' 'Texture2DMSArray':'Texture2DMSArray, 8>' @@ -486,6 +668,10 @@ float4 test_sample_double_indexing() `-ImplicitCastExpr 'uint3':'vector' `-DeclRefExpr 'uint3':'vector' lvalue Var 'pos3' 'uint3':'vector' */ + + g_t2dms.sample[sampleSlice][pos2] = f4; /* expected-error {{cannot assign to return value because function 'operator[] &>' 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[] &>' returns a const value}} fxc-error {{X3025: l-value specifies const object}} */ + return f4; } diff --git a/tools/clang/test/HLSLFileCheck/validation/rawbufferstore_uav.hlsl b/tools/clang/test/HLSLFileCheck/validation/rawbufferstore_uav.hlsl index 8498ed179..f46dc02f2 100644 --- a/tools/clang/test/HLSLFileCheck/validation/rawbufferstore_uav.hlsl +++ b/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 -// CHECK: store should be on uav resource +// CHECK: error: cannot assign to return value because function 'operator[]' returns a const value StructuredBuffer buf; void main() { buf[0] = 0; } \ No newline at end of file diff --git a/utils/hct/VerifierHelper.py b/utils/hct/VerifierHelper.py index d02bbc81e..92d01a1c2 100644 --- a/utils/hct/VerifierHelper.py +++ b/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') HlslBinDir = os.path.expandvars(r'${HLSL_BLD_DIR}\Debug\bin') VerifierTests = { + 'RunArrayIndexOutOfBounds': 'array-index-out-of-bounds-HV-2016.hlsl', + 'RunArrayLength': 'array-length.hlsl', 'RunAttributes': 'attributes.hlsl', 'RunBadInclude': 'bad-include.hlsl', 'RunBinopDims': 'binop-dims.hlsl', + 'RunBuiltinTypesNoInheritance': 'builtin-types-no-inheritance.hlsl', 'RunCXX11Attributes': 'cxx11-attributes.hlsl', 'RunConstAssign': 'const-assign.hlsl', 'RunConstDefault': 'const-default.hlsl', 'RunConstExpr': 'const-expr.hlsl', + 'RunConversionsBetweenTypeShapes': 'conversions-between-type-shapes.hlsl', + 'RunConversionsNonNumericAggregates': 'conversions-non-numeric-aggregates.hlsl', 'RunCppErrors': 'cpp-errors.hlsl', 'RunCppErrorsHV2015': 'cpp-errors-hv2015.hlsl', 'RunDerivedToBaseCasts': 'derived-to-base.hlsl', @@ -62,12 +67,15 @@ VerifierTests = { 'RunEnums': 'enums.hlsl', 'RunFunctions': 'functions.hlsl', 'RunImplicitCasts': 'implicit-casts.hlsl', + 'RunIncompleteArray': 'incomp_array_err.hlsl', + 'RunIncompleteType': 'incomplete-type.hlsl', 'RunIndexingOperator': 'indexing-operator.hlsl', 'RunIntrinsicExamples': 'intrinsic-examples.hlsl', 'RunLiterals': 'literals.hlsl', 'RunMatrixAssignments': 'matrix-assignments.hlsl', 'RunMatrixSyntax': 'matrix-syntax.hlsl', 'RunMatrixSyntaxExactPrecision': 'matrix-syntax-exact-precision.hlsl', + 'RunMintypesPromotionWarnings': 'mintypes-promotion-warnings.hlsl', 'RunMoreOperators': 'more-operators.hlsl', 'RunObjectOperators': 'object-operators.hlsl', 'RunPackReg': 'packreg.hlsl', @@ -79,6 +87,7 @@ VerifierTests = { 'RunScalarOperatorsAssignExactPrecision': 'scalar-operators-assign-exact-precision.hlsl', 'RunScalarOperatorsExactPrecision': 'scalar-operators-exact-precision.hlsl', 'RunSemantics': 'semantics.hlsl', + 'RunSizeof': 'sizeof.hlsl', 'RunString': 'string.hlsl', 'RunStructAssignments': 'struct-assignments.hlsl', 'RunSubobjects': 'subobjects-syntax.hlsl', @@ -100,6 +109,7 @@ fxcExcludedTests = [ 'RunCppErrorsHV2015', 'RunCXX11Attributes', 'RunEnums', + 'RunIncompleteType', 'RunIntrinsicExamples', 'RunMatrixSyntaxExactPrecision', 'RunRayTracings', @@ -578,7 +588,7 @@ class File(object): result[i] = line, diag_col, expected 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): 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) state = 'WaitingForCategory' continue - if state is 'WaitingForFile': + if state == 'WaitingForFile': m = rxEndGroup.match(line) if m and m.group(2) == 'Failed': # This usually happens when compiler crashes 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) if m: ew = m.group(1) expected = m.group(2) == 'expected but not seen' state = 'ReadingErrors' continue - if state is 'ReadingErrors': + if state == 'ReadingErrors': m = rxDiagReport.match(line) if m: line_num = int(m.group(2))