Skip to content
Merged
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
4 changes: 2 additions & 2 deletions clang/lib/Parse/ParseHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ static bool validateDeclsInsideHLSLBuffer(Parser::DeclGroupPtrTy DG,
return false;
DeclGroupRef Decls = DG.get();
bool IsValid = true;
// Only allow function, variable, record decls inside HLSLBuffer.
// Only allow function, variable, record, and empty decls inside HLSLBuffer.
for (DeclGroupRef::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
Decl *D = *I;
if (isa<CXXRecordDecl, RecordDecl, FunctionDecl, VarDecl>(D))
if (isa<CXXRecordDecl, RecordDecl, FunctionDecl, VarDecl, EmptyDecl>(D))
continue;

// FIXME: support nested HLSLBuffer and namespace inside HLSLBuffer.
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaHLSL/cb_error.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ tbuffer B {
// expected-error@+1 {{unknown type name 'flaot'}}
flaot f;
}

// None of these should produce an error!
cbuffer EmptyCBuffer {}

cbuffer EmptyDeclCBuffer {
;
}

cbuffer EmptyDecl2CBuffer {
;
int X;
}