File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1363,9 +1363,12 @@ const Init *BinOpInit::Fold(const Record *CurRec) const {
13631363 }
13641364 case LISTSPLAT: {
13651365 const auto *Value = dyn_cast<TypedInit>(LHS);
1366- const auto *Size = dyn_cast<IntInit>(RHS);
1367- if (Value && Size) {
1368- SmallVector<const Init *, 8 > Args (Size->getValue (), Value);
1366+ const auto *Count = dyn_cast<IntInit>(RHS);
1367+ if (Value && Count) {
1368+ if (Count->getValue () < 0 )
1369+ PrintFatalError (Twine (" !listsplat count " ) + Count->getAsString () +
1370+ " is negative" );
1371+ SmallVector<const Init *, 8 > Args (Count->getValue (), Value);
13691372 return ListInit::get (Args, Value->getType ());
13701373 }
13711374 break ;
Original file line number Diff line number Diff line change 11// RUN: llvm-tblgen %s | FileCheck %s
2+ // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
23
34// CHECK: ------------- Classes -----------------
45// CHECK-NEXT: class X<int X:a = ?, int X:b = ?> {
@@ -73,3 +74,8 @@ def DYa1 : Y<"a", 1>;
7374def DYa2 : Y<"a", 2>;
7475
7576def DZ : X<42, !size([1, 2, 3])>;
77+
78+ #ifdef ERROR1
79+ // ERROR1: !listsplat count -1 is negative
80+ defvar E = !listsplat("", -1);
81+ #endif
You can’t perform that action at this time.
0 commit comments