Skip to content

Commit b79e4dd

Browse files
committed
Handle register(u-1);
1 parent 7084cf1 commit b79e4dd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clang/lib/Parse/ParseHLSL.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,16 @@ void Parser::ParseHLSLAnnotations(ParsedAttributes &Attrs,
163163
SourceLocation SlotLoc = Tok.getLocation();
164164
ArgExprs.push_back(ParseIdentifierLoc());
165165

166-
// Add numeric_constant for fix-it.
167-
if (SlotStr.size() == 1 && Tok.is(tok::numeric_constant))
166+
if (SlotStr.size() == 1) {
167+
if (!Tok.is(tok::numeric_constant)) {
168+
Diag(Tok.getLocation(), diag::err_expected) << tok::numeric_constant;
169+
SkipUntil(tok::r_paren, StopAtSemi); // skip through )
170+
return;
171+
}
172+
// Add numeric_constant for fix-it.
168173
fixSeparateAttrArgAndNumber(SlotStr, SlotLoc, Tok, ArgExprs, *this,
169174
Actions.Context, PP);
170-
175+
}
171176
if (Tok.is(tok::comma)) {
172177
ConsumeToken(); // consume comma
173178
if (!Tok.is(tok::identifier)) {

clang/test/SemaHLSL/resource_binding_attr_error.hlsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ cbuffer C : register(b 2) {}
3131
// expected-error@+1 {{wrong argument format for hlsl attribute, use b2 instead}}
3232
cbuffer D : register(b 2, space3) {}
3333

34+
// expected-error@+1 {{expected <numeric_constant>}}
35+
cbuffer E : register(u-1) {};
36+
3437
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
3538
static MyTemplatedSRV<float> U : register(u5);
3639

0 commit comments

Comments
 (0)