llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Martin Storsjö (mstorsjo) <details> <summary>Changes</summary> This avoids the following kind of warning when built with GCC: ../../clang/lib/Sema/SemaStmtAttr.cpp: In function ‘clang::Attr* ProcessStmtAttribute(clang::Sema&, clang::Stmt*, const clang::ParsedAttr&, clang::SourceRange)’: ../../clang/lib/Sema/SemaStmtAttr.cpp:677:30: warning: enumerated mismatch in conditional expression: ‘clang::diag::<unnamed enum>’ vs ‘clang::diag::<unnamed enum>’ [-Wenum-compare] 676 | S.Diag(A.getLoc(), A.isRegularKeywordAttribute() | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 677 | ? diag::err_keyword_not_supported_on_targe | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 678 | : diag::warn_unhandled_ms_attribute_ignore ) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These enums are non-overlapping, but due they are defined in different enum scopes due to how they are generated with tablegen. --- Full diff: https://github.com/llvm/llvm-project/pull/159338.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+4-2) - (modified) clang/lib/Sema/SemaStmtAttr.cpp (+4-2) ``````````diff diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 44906456f3371..7b3dc80e38913 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6837,8 +6837,10 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, !AL.existsInTarget(S.Context.getTargetInfo())) { if (AL.isRegularKeywordAttribute() || AL.isDeclspecAttribute()) { S.Diag(AL.getLoc(), AL.isRegularKeywordAttribute() - ? diag::err_keyword_not_supported_on_target - : diag::warn_unhandled_ms_attribute_ignored) + ? static_cast<unsigned>( + diag::err_keyword_not_supported_on_target) + : static_cast<unsigned>( + diag::warn_unhandled_ms_attribute_ignored)) << AL.getAttrName() << AL.getRange(); } else { S.DiagnoseUnknownAttribute(AL); diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 77aa7164d4555..8cac790e969fa 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -674,8 +674,10 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A, A.existsInTarget(*Aux)))) { if (A.isRegularKeywordAttribute() || A.isDeclspecAttribute()) { S.Diag(A.getLoc(), A.isRegularKeywordAttribute() - ? diag::err_keyword_not_supported_on_target - : diag::warn_unhandled_ms_attribute_ignored) + ? static_cast<unsigned>( + diag::err_keyword_not_supported_on_target) + : static_cast<unsigned>( + diag::warn_unhandled_ms_attribute_ignored)) << A << A.getRange(); } else { S.DiagnoseUnknownAttribute(A); `````````` </details> https://github.com/llvm/llvm-project/pull/159338 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits