Skip to content

Commit c7d2fc3

Browse files
committed
[clang][Sema] Avoid warnings when mixing diagnostic categories (NFC)
These statements conditionally select between diagnostics of different categories (common vs. sema). Although the diagnostic IDs do not overlap between categories, they are organized in different enums, and this raises warnings in specific compilers. The clang warning suggest this behavior is deprecated in C++20. By converting the diagnostic IDs to unsigned, we avoid the issue.
1 parent a134b06 commit c7d2fc3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6836,9 +6836,10 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
68366836
if (AL.getKind() == ParsedAttr::UnknownAttribute ||
68376837
!AL.existsInTarget(S.Context.getTargetInfo())) {
68386838
if (AL.isRegularKeywordAttribute() || AL.isDeclspecAttribute()) {
6839-
S.Diag(AL.getLoc(), AL.isRegularKeywordAttribute()
6840-
? diag::err_keyword_not_supported_on_target
6841-
: diag::warn_unhandled_ms_attribute_ignored)
6839+
S.Diag(AL.getLoc(),
6840+
AL.isRegularKeywordAttribute()
6841+
? (unsigned)diag::err_keyword_not_supported_on_target
6842+
: (unsigned)diag::warn_unhandled_ms_attribute_ignored)
68426843
<< AL.getAttrName() << AL.getRange();
68436844
} else {
68446845
S.DiagnoseUnknownAttribute(AL);

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,10 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A,
673673
(S.Context.getLangOpts().SYCLIsDevice && Aux &&
674674
A.existsInTarget(*Aux)))) {
675675
if (A.isRegularKeywordAttribute() || A.isDeclspecAttribute()) {
676-
S.Diag(A.getLoc(), A.isRegularKeywordAttribute()
677-
? diag::err_keyword_not_supported_on_target
678-
: diag::warn_unhandled_ms_attribute_ignored)
676+
S.Diag(A.getLoc(),
677+
A.isRegularKeywordAttribute()
678+
? (unsigned)diag::err_keyword_not_supported_on_target
679+
: (unsigned)diag::warn_unhandled_ms_attribute_ignored)
679680
<< A << A.getRange();
680681
} else {
681682
S.DiagnoseUnknownAttribute(A);

0 commit comments

Comments
 (0)