diff --git a/llvm/test/TableGen/generic-tables.td b/llvm/test/TableGen/generic-tables.td --- a/llvm/test/TableGen/generic-tables.td +++ b/llvm/test/TableGen/generic-tables.td @@ -1,4 +1,5 @@ // RUN: llvm-tblgen -gen-searchable-tables -I %p/../../include %s | FileCheck %s +// RUN: not llvm-tblgen -gen-searchable-tables -I %p/../../include -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s // XFAIL: vg_leak include "llvm/TableGen/SearchableTable.td" @@ -136,3 +137,21 @@ let Table = CTable; let Key = ["Name", "Kind"]; } + +#ifdef ERROR1 + +class DEntry { + string Str = str; + bits<8> Val1 = val1; +} + +def DFoo : DEntry<"foo", 1>; +// ERROR1: [[@LINE+1]]:1: error: Record 'DBar' in table 'DTable' is missing field 'Val1' +def DBar : DEntry<"bar", ?>; + +def DTable : GenericTable { + let FilterClass = "DEntry"; + let Fields = ["Str", "Val1"]; +} + +#endif // ERROR1 diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp --- a/llvm/utils/TableGen/SearchableTableEmitter.cpp +++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp @@ -599,7 +599,7 @@ for (auto EntryRec : Items) { for (auto &Field : Table.Fields) { auto TI = dyn_cast(EntryRec->getValueInit(Field.Name)); - if (!TI) { + if (!TI || !TI->isComplete()) { PrintFatalError(EntryRec->getLoc(), Twine("Record '") + EntryRec->getName() + "' in table '" + Table.Name +