diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -593,10 +593,11 @@ for (auto *UnsolvedArgName : UnsolvedArgNames) { Init *Default = Rec->getValue(UnsolvedArgName)->getValue(); if (!Default->isComplete()) { - return Error(Loc, "value not specified for template argument (" + - UnsolvedArgName->getAsUnquotedString() + - ") of multiclass '" + Rec->getNameInitAsString() + - "'"); + std::string Name = UnsolvedArgName->getAsUnquotedString(); + Error(Loc, "value not specified for template argument '" + Name + "'"); + PrintNote(Rec->getFieldLoc(Name), + "declared in '" + Rec->getNameInitAsString() + "'"); + return true; } ArgValueHandler(UnsolvedArgName, Default); } diff --git a/llvm/test/TableGen/template-args.td b/llvm/test/TableGen/template-args.td --- a/llvm/test/TableGen/template-args.td +++ b/llvm/test/TableGen/template-args.td @@ -6,9 +6,12 @@ // RUN: not llvm-tblgen -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s // RUN: not llvm-tblgen -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s // RUN: not llvm-tblgen -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s +// RUN: not llvm-tblgen -DERROR8 %s 2>&1 | FileCheck --check-prefix=ERROR8 %s +// RUN: not llvm-tblgen -DERROR9 %s 2>&1 | FileCheck --check-prefix=ERROR9 %s +// RUN: not llvm-tblgen -DERROR10 %s 2>&1 | FileCheck --check-prefix=ERROR10 %s -// This file tests that template arguments are type-checked and cast -// if necessary. +// This file tests that all required arguments are specified and template +// arguments are type-checked and cast if necessary. // Class template arguments. @@ -151,3 +154,23 @@ defm MissingComma : TwoArgs<2 "two">; // ERROR7: [[#@LINE-1]]:31: error: Expected comma before next argument #endif + +#ifdef ERROR8 +def error8: Class1; +// ERROR8: value not specified for template argument 'Class1:nm' +// ERROR8: 18:21: note: declared in 'Class1' +#endif + +#ifdef ERROR9 +defm error9: MC1; +// ERROR9: value not specified for template argument 'MC1::nm' +// ERROR9: 99:23: note: declared in 'MC1' +#endif + +#ifdef ERROR10 +def error10 { + int value = Class2<>.Code; +} +// ERROR10: value not specified for template argument 'Class2:cd' +// ERROR10: 37:22: note: declared in 'Class2' +#endif