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 @@ -2539,9 +2539,9 @@ if (consume(tgtok::greater)) // end of argument list? return false; - if (!consume(tgtok::comma)) // must be comma - return true; - ++ArgIndex; + if (!consume(tgtok::comma)) + return TokError("Expected comma before next argument"); + ++ArgIndex; } } 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 @@ -5,6 +5,7 @@ // RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s // 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 // This file tests that template arguments are type-checked and cast // if necessary. @@ -140,3 +141,13 @@ defm RecMC4 : MC2<"Bob">; #endif + +#ifdef ERROR7 +multiclass TwoArgs a, string b> { + def _1 { bits<8> A = a; } + def _2 { string B = b; } +} +defm Good : TwoArgs<1, "one">; +defm MissingComma : TwoArgs<2 "two">; +// ERROR7: [[#@LINE-1]]:31: error: Expected comma before next argument +#endif