[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 27 04:30:57 PDT 2025


================
@@ -4338,6 +4338,21 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
                                        E->getSourceRange(), ExprKind))
     return true;
 
+  if (ExprKind == UETT_CountOf) {
+    // The type has to be an array type. We already checked for incomplete
+    // types above.
+    QualType ExprType = E->IgnoreParens()->getType();
+    if (!ExprType->isArrayType()) {
+      Diag(E->getExprLoc(), diag::err_countof_arg_not_array_type) << ExprType;
+      return true;
----------------
AaronBallman wrote:

Absolutely!

https://github.com/llvm/llvm-project/pull/133125


More information about the cfe-commits mailing list