Skip to content

Commit cc28158

Browse files
committed
Revert "[clang][ExprConst] Check for array size of initlists (#138673)"
This reverts commit d35ad58. This breaks the clang build: https://lab.llvm.org/buildbot/#/builders/132/builds/1033 /home/buildbot-worker/bbroot/clang-riscv-rva23-evl-vec-2stage/stage2/lib/Target/RISCV/RISCVGenGlobalISel.inc:1512:44: note: cannot allocate array; evaluated array bound 2431270 exceeds the limit (1048576); use '-fconstexpr-steps' to increase this limit
1 parent 5f530b1 commit cc28158

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11788,11 +11788,6 @@ bool ArrayExprEvaluator::VisitCXXParenListOrInitListExpr(
1178811788
LLVM_DEBUG(llvm::dbgs() << "The number of elements to initialize: "
1178911789
<< NumEltsToInit << ".\n");
1179011790

11791-
if (!Info.CheckArraySize(ExprToVisit->getExprLoc(),
11792-
CAT->getNumAddressingBits(Info.Ctx), NumEltsToInit,
11793-
/*Diag=*/true))
11794-
return false;
11795-
1179611791
Result = APValue(APValue::UninitArray(), NumEltsToInit, NumElts);
1179711792

1179811793
// If the array was previously zero-initialized, preserve the
@@ -11924,9 +11919,6 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
1192411919
if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(Type)) {
1192511920
unsigned FinalSize = CAT->getZExtSize();
1192611921

11927-
if (!CheckArraySize(Info, CAT, E->getExprLoc()))
11928-
return false;
11929-
1193011922
// Preserve the array filler if we had prior zero-initialization.
1193111923
APValue Filler =
1193211924
HadZeroInit && Value->hasArrayFiller() ? Value->getArrayFiller()

clang/test/SemaCXX/constant-expression-cxx2a.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,45 +1497,3 @@ namespace GH67317 {
14971497
// expected-note {{subobject of type 'const unsigned char' is not initialized}}
14981498
__builtin_bit_cast(unsigned char, *new char[3][1]);
14991499
};
1500-
1501-
namespace GH138653 {
1502-
constexpr unsigned kNumberOfIterations = 2000000;
1503-
constexpr unsigned kThreadsNumber = 2 * 8 * 1024;
1504-
1505-
/// Large array initialized by Paren/InitListExpr.
1506-
template <typename T, unsigned long S>
1507-
struct array1 {
1508-
using AT = T[S];
1509-
AT Data{};
1510-
constexpr array1() : Data(T()) {} // expected-note {{cannot allocate array}}
1511-
};
1512-
1513-
/// And initialized by a CXXConstructExpr.
1514-
template <typename T, unsigned long S>
1515-
struct array2 {
1516-
using AT = T[S];
1517-
AT Data;
1518-
constexpr array2() {} // expected-note {{cannot allocate array}}
1519-
};
1520-
1521-
template <typename T>
1522-
class A{};
1523-
int main() {
1524-
array1<A<short*>, kThreadsNumber * kNumberOfIterations> futures1{};
1525-
array2<A<short*>, kThreadsNumber * kNumberOfIterations> futures2{};
1526-
}
1527-
1528-
constexpr int CE1() {
1529-
array1<A<short*>, kThreadsNumber * kNumberOfIterations> futures1{}; // expected-note {{in call to}}
1530-
return 1;
1531-
}
1532-
static_assert(CE1() == 1); // expected-error {{not an integral constant expression}} \
1533-
// expected-note {{in call to}}
1534-
1535-
constexpr int CE2() {
1536-
array2<A<short*>, kThreadsNumber * kNumberOfIterations> futures2{}; // expected-note {{in call to}}
1537-
return 1;
1538-
}
1539-
static_assert(CE2() == 1); // expected-error {{not an integral constant expression}} \
1540-
// expected-note {{in call to}}
1541-
}

0 commit comments

Comments
 (0)