Skip to content

Commit 98d8a84

Browse files
committed
[HLSL] Allow EmptyDecl in cbuffer/tbuffer
We do handle EmptyDecls in codegen already as of llvm#124886, but we were blocking them in Sema. EmptyDecls tend to be caused by extra semicolons which are not illegal. Fixes llvm#128238
1 parent 61c6e00 commit 98d8a84

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clang/lib/Parse/ParseHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static bool validateDeclsInsideHLSLBuffer(Parser::DeclGroupPtrTy DG,
3030
// Only allow function, variable, record decls inside HLSLBuffer.
3131
for (DeclGroupRef::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
3232
Decl *D = *I;
33-
if (isa<CXXRecordDecl, RecordDecl, FunctionDecl, VarDecl>(D))
33+
if (isa<CXXRecordDecl, RecordDecl, FunctionDecl, VarDecl, EmptyDecl>(D))
3434
continue;
3535

3636
// FIXME: support nested HLSLBuffer and namespace inside HLSLBuffer.

clang/test/SemaHLSL/cb_error.hlsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ tbuffer B {
4747
// expected-error@+1 {{unknown type name 'flaot'}}
4848
flaot f;
4949
}
50+
51+
// None of these should produce an error!
52+
cbuffer EmptyCBuffer {}
53+
54+
cbuffer EmptyDeclCBuffer {
55+
;
56+
}
57+
58+
cbuffer EmptyDecl2CBuffer {
59+
;
60+
int X;
61+
}

0 commit comments

Comments
 (0)