Fix assertion on `!eq(?, 0)`

Instead of asserting, emit a proper error message
This commit is contained in:
Daniel Sanders 2020-02-18 13:12:28 -08:00
parent 9d37f5afac
commit 2c8ee5329b
2 changed files with 16 additions and 1 deletions

View File

@ -1180,7 +1180,13 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
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;

View File

@ -0,0 +1,9 @@
// 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);
}