Skip to content

Commit a744555

Browse files
committed
review: update duplicate attrs warning/error
1 parent a616395 commit a744555

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,16 @@ void SemaHLSL::handleRootSignatureAttr(Decl *D, const ParsedAttr &AL) {
957957
}
958958

959959
IdentifierInfo *Ident = AL.getArgAsIdent(0)->getIdentifierInfo();
960+
if (auto *RS = D->getAttr<RootSignatureAttr>()) {
961+
if (RS->getSignature() != Ident) {
962+
Diag(AL.getLoc(), diag::err_disallowed_duplicate_attribute) << RS;
963+
return;
964+
}
965+
966+
Diag(AL.getLoc(), diag::warn_duplicate_attribute_exact) << RS;
967+
return;
968+
}
969+
960970
LookupResult R(SemaRef, Ident, SourceLocation(), Sema::LookupOrdinaryName);
961971
if (SemaRef.LookupQualifiedName(R, D->getDeclContext()))
962972
if (auto *SignatureDecl =

clang/test/SemaHLSL/RootSignature-err.hlsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ void bad_root_signature_0() {}
99
// expected-note@+1 {{to match this '('}}
1010
[RootSignature("", "")]
1111
void bad_root_signature_1() {}
12+
13+
[RootSignature(""), RootSignature("DescriptorTable()")] // expected-error {{attribute 'RootSignature' cannot appear more than once on a declaration}}
14+
void bad_root_signature_2() {}
15+
16+
[RootSignature(""), RootSignature("")] // expected-warning {{attribute 'RootSignature' is already applied}}
17+
void bad_root_signature_3() {}

0 commit comments

Comments
 (0)