[clang] [clang][Sema] Recheck array size once the element type is complete (PR #219817)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 06:25:26 PDT 2026


================
@@ -9739,6 +9761,20 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
                               /*Recover*/ TreatAsComplete);
       return !TreatAsComplete;
     }
+
+    // The element type may have been incomplete when the array type was
+    // formed, in which case BuildArrayType could not check the array's size.
+    if (T->isConstantArrayType() && !T->isDependentType() &&
+        !T->isVariablyModifiedType() && !T->isUndeducedType()) {
+      if (const ConstantArrayType *CAT = findArrayTypeTooLarge(Context, T)) {
+        if (Diagnoser)
+          Diag(Loc, diag::err_array_too_large)
+              << toString(CAT->getSize(), 10, /*Signed=*/false,
----------------
erichkeane wrote:

APInt already has a operator<<, why are you doing the `toString` stuff here? 

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


More information about the cfe-commits mailing list