Instead of asserting, emit a proper error message
InitList.push_back(ParseValue(CurRec, ArgType));
if (!InitList.back()) return nullptr;
- RecTy *ListType = cast<TypedInit>(InitList.back())->getType();
+ TypedInit *InitListBack = dyn_cast<TypedInit>(InitList.back());
+ if (!InitListBack) {
+ Error(OpLoc, Twine("expected value to be a typed value, got '" +
+ InitList.back()->getAsString() + "'"));
+ return nullptr;
+ }
+ RecTy *ListType = InitListBack->getType();
if (!ArgType) {
ArgType = ListType;
--- /dev/null
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s
+
+// CHECK: error: expected value to be a typed value, got '?'
+
+def Z1 {
+ // This one caused an assertion because the value was an UnsetInit
+ // and !eq() can only accept TypedInit's.
+ bit D = !if(!eq(?, 0), 1, 0);
+}