[PATCH] D100178: [TableGen] Report an error message on a missing comma
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 9 04:48:42 PDT 2021
arichardson updated this revision to Diff 336399.
arichardson added a comment.
Herald added a subscriber: mstorsjo.
Add a test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100178/new/
https://reviews.llvm.org/D100178
Files:
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/template-args.td
Index: llvm/test/TableGen/template-args.td
===================================================================
--- llvm/test/TableGen/template-args.td
+++ 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<bits<8> 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
Index: llvm/lib/TableGen/TGParser.cpp
===================================================================
--- llvm/lib/TableGen/TGParser.cpp
+++ 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;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100178.336399.patch
Type: text/x-patch
Size: 1433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210409/2db129b4/attachment.bin>
More information about the llvm-commits
mailing list