Index: llvm/trunk/lib/TableGen/TGParser.cpp =================================================================== --- llvm/trunk/lib/TableGen/TGParser.cpp +++ llvm/trunk/lib/TableGen/TGParser.cpp @@ -536,8 +536,14 @@ } Record *Result = Records.getClass(Lex.getCurStrVal()); - if (!Result) - TokError("Couldn't find class '" + Lex.getCurStrVal() + "'"); + if (!Result) { + std::string Msg("Couldn't find class '" + Lex.getCurStrVal() + "'"); + if (MultiClasses[Lex.getCurStrVal()].get()) + TokError(Msg + ". Use 'defm' if you meant to use multiclass '" + + Lex.getCurStrVal() + "'"); + else + TokError(Msg); + } Lex.Lex(); return Result; Index: llvm/trunk/test/TableGen/MultiClass-def-fail.td =================================================================== --- llvm/trunk/test/TableGen/MultiClass-def-fail.td +++ llvm/trunk/test/TableGen/MultiClass-def-fail.td @@ -0,0 +1,10 @@ +// RUN: not llvm-tblgen %s 2>&1 | FileCheck %s +// XFAIL: vg_leak + +// This test checks that using def instead of defm gives a meaningful error +multiclass M2 { + def X; +} + +// CHECK: error: Couldn't find class 'M2'. Use 'defm' if you meant to use multiclass 'M2' +def rec1 : M2;