[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 2 07:04:21 PST 2024
================
@@ -11854,14 +11854,23 @@ static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc,
AlwaysEqual, // std::strong_ordering::equal from operator<=>
};
+ // C++1a [array.comp]:
+ // Equality and relational comparisons ([expr.eq], [expr.rel]) between two
+ // operands of array type.
// C++2a [depr.array.comp]:
// Equality and relational comparisons ([expr.eq], [expr.rel]) between two
// operands of array type are deprecated.
- if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+ if (S.getLangOpts().CPlusPlus && LHSStripped->getType()->isArrayType() &&
RHSStripped->getType()->isArrayType()) {
- S.Diag(Loc, diag::warn_depr_array_comparison)
- << LHS->getSourceRange() << RHS->getSourceRange()
- << LHSStripped->getType() << RHSStripped->getType();
+ auto IsDeprArrayComparionIgnored =
+ S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+ auto IsDeprArrayComparion =
+ !S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+ auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
----------------
cor3ntin wrote:
this looks inverted
https://github.com/llvm/llvm-project/pull/118031
More information about the cfe-commits
mailing list