Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unsigned as a full type #6885

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions tools/clang/lib/Sema/DeclSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 27 additions & 0 deletions tools/clang/test/CodeGenHLSL/unsigned-int.hlsl
Original file line number Diff line number Diff line change
@@ -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<unsigned int>", align 4
// CHECK: @"\01?sbuf_u@@3V?$RWStructuredBuffer@I@@A" = external global %"class.RWStructuredBuffer<unsigned int>", align 4
RWBuffer<uint> buf_u;
RWStructuredBuffer<unsigned> 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<unsigned>(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;
}
Loading