[clang] [clang] Reject array comparisons in C++26 for unknown/dependent types in templates (PR #191101)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 29 12:02:15 PDT 2026
================
@@ -12860,6 +12837,33 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
return Ty->isPointerType() || Ty->isMemberPointerType();
};
+ // 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.
+ Expr *LHSStripped = LHS.get()->IgnoreParenImpCasts();
+ Expr *RHSStripped = RHS.get()->IgnoreParenImpCasts();
+ if (getLangOpts().CPlusPlus && LHSStripped->getType()->isArrayType() &&
+ RHSStripped->getType()->isArrayType()) {
+
+ // In an SFINAE context, don't emit an error.
+ // Just return the operands so the caller can return false.
+ if (isSFINAEContext()) {
+ return InvalidOperands(Loc, LHS, RHS);
+ }
----------------
Sirraide wrote:
```suggestion
```
You shouldn’t need this; Sema generally automatically suppresses errors when appropriate if we’re in a SFINAE context.
https://github.com/llvm/llvm-project/pull/191101
More information about the cfe-commits
mailing list