diff --git a/tools/clang/lib/Sema/DeclSpec.cpp b/tools/clang/lib/Sema/DeclSpec.cpp index 37c1554092..f77031a586 100644 --- a/tools/clang/lib/Sema/DeclSpec.cpp +++ b/tools/clang/lib/Sema/DeclSpec.cpp @@ -1051,13 +1051,11 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP, const PrintingPoli // signed/unsigned are only valid with int/char/wchar_t. if (TypeSpecSign != TSS_unspecified) { - // HLSL Change starts - signed/unsigned are not complete type specifiers. - #if 0 if (TypeSpecType == TST_unspecified) TypeSpecType = TST_int; - #endif - // shorthand vectors and matrices can have signed/unsigned specifiers. - // If other typenames are used with signed/unsigned, it is already diagnosed by hlsl external source + // HLSL Change starts - shorthand vectors and matrices can have + // signed/unsigned specifiers. If other typenames are used with + // signed/unsigned, it is already diagnosed by hlsl external source if (TypeSpecType != TST_int && TypeSpecType != TST_int128 && TypeSpecType != TST_char && TypeSpecType != TST_wchar && TypeSpecType != TST_typename) { diff --git a/tools/clang/test/CodeGenHLSL/unsigned-int.hlsl b/tools/clang/test/CodeGenHLSL/unsigned-int.hlsl new file mode 100644 index 0000000000..8422ecb981 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/unsigned-int.hlsl @@ -0,0 +1,27 @@ +// RUN: %dxc -fcgl -T vs_6_0 %s | FileCheck %s + +// Test that unsigned alone is accepted and equivalent to an unsigned int + +// CHECK: @"\01?g_u@@3IB" = external constant i32, align 4 +unsigned g_u; + +// CHECK: @"\01?buf_u@@3V?$RWBuffer@I@@A" = external global %"class.RWBuffer", align 4 +// CHECK: @"\01?sbuf_u@@3V?$RWStructuredBuffer@I@@A" = external global %"class.RWStructuredBuffer", align 4 +RWBuffer buf_u; +RWStructuredBuffer sbuf_u; +RWByteAddressBuffer bab_u; + +unsigned doit(uint i, unsigned j); + +float4 main(unsigned VID : SV_VertexID, unsigned IID : SV_InstanceID) : SV_Position { + uint i = g_u; + // CHECK: %call = call i32 @"\01?doit@@YAIII@Z"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) + buf_u[0] = doit(VID, i); + sbuf_u[0] = doit(IID, bab_u.Load(0)); + return doit(buf_u[1], sbuf_u[1]); +} + +// CHECK: define internal i32 @"\01?doit@@YAIII@Z"(i32 %i, i32 %j) +unsigned doit(uint i, unsigned j) { + return i + j; +}