================
@@ -2293,6 +2297,20 @@ void InitListChecker::CheckArrayType(const 
InitializedEntity &Entity,
       SemaRef.Diag(IList->getBeginLoc(), diag::ext_typecheck_zero_array_size);
     }
 
+    unsigned ActiveSizeBits = maxElements.getActiveBits();
+    if (!elementType->isDependentType() && !elementType->isIncompleteType())
+      ActiveSizeBits = std::max(ActiveSizeBits,
+                                ConstantArrayType::getNumAddressingBits(
+                                    SemaRef.Context, elementType, 
maxElements));
+    if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(SemaRef.Context)) {
+      SemaRef.Diag(IList->getBeginLoc(), diag::err_array_too_large)
+          << toString(maxElements, 10, maxElements.isSigned(),
+                      /*formatAsCLiteral=*/false, /*UpperCase=*/false,
+                      /*InsertSeparators=*/true);
+      hadError = true;
+      return;
+    }
+
----------------
cor3ntin wrote:

We have the same code in Sema::BuildArrayType, Sema::BuildCXXNew, and here.
Can you make a function?

https://github.com/llvm/llvm-project/pull/226983
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to