Skip to content

Commit a0fd705

Browse files
committed
review: update duplicate attrs warning/error
1 parent 6e842d7 commit a0fd705

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
@@ -958,6 +958,16 @@ void SemaHLSL::handleRootSignatureAttr(Decl *D, const ParsedAttr &AL) {
958958
}
959959

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