diff --git a/support/tools/TableGen/FileParser.y b/support/tools/TableGen/FileParser.y index f8fa16de2a5..55938f47ea7 100644 --- a/support/tools/TableGen/FileParser.y +++ b/support/tools/TableGen/FileParser.y @@ -245,6 +245,10 @@ Value : INTVAL { $$ = Init; delete $2; } | ID { + if (CurRec == 0) { + err() << "Def/Class name '" << *$1 << "' not allowed here!\n"; + abort(); + } if (const RecordVal *RV = CurRec->getValue(*$1)) { $$ = new VarInit(*$1, RV->getType()); } else if (Record *D = Records.getDef(*$1)) { diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index f8fa16de2a5..55938f47ea7 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -245,6 +245,10 @@ Value : INTVAL { $$ = Init; delete $2; } | ID { + if (CurRec == 0) { + err() << "Def/Class name '" << *$1 << "' not allowed here!\n"; + abort(); + } if (const RecordVal *RV = CurRec->getValue(*$1)) { $$ = new VarInit(*$1, RV->getType()); } else if (Record *D = Records.getDef(*$1)) {