@@ -2836,7 +2836,7 @@ bool TGParser::ParseBody(Record *CurRec) {
2836
2836
return false ;
2837
2837
2838
2838
if (!consume (tgtok::l_brace))
2839
- return TokError (" Expected ';' or '{' to start body " );
2839
+ return TokError (" Expected '{' to start body or ';' for declaration only " );
2840
2840
2841
2841
// An object body introduces a new scope for local variables.
2842
2842
TGLocalVarScope *BodyScope = PushLocalScope ();
@@ -2849,6 +2849,14 @@ bool TGParser::ParseBody(Record *CurRec) {
2849
2849
2850
2850
// Eat the '}'.
2851
2851
Lex.Lex ();
2852
+
2853
+ // If we have a semicolon, print a gentle error.
2854
+ SMLoc SemiLoc = Lex.getLoc ();
2855
+ if (consume (tgtok::semi)) {
2856
+ PrintError (SemiLoc, " A class or def body should not end with a semicolon" );
2857
+ PrintNote (" Semicolon ignored; remove to eliminate this error" );
2858
+ }
2859
+
2852
2860
return false ;
2853
2861
}
2854
2862
@@ -3432,6 +3440,13 @@ bool TGParser::ParseMultiClass() {
3432
3440
}
3433
3441
Lex.Lex (); // eat the '}'.
3434
3442
3443
+ // If we have a semicolon, print a gentle error.
3444
+ SMLoc SemiLoc = Lex.getLoc ();
3445
+ if (consume (tgtok::semi)) {
3446
+ PrintError (SemiLoc, " A multiclass body should not end with a semicolon" );
3447
+ PrintNote (" Semicolon ignored; remove to eliminate this error" );
3448
+ }
3449
+
3435
3450
PopLocalScope (MulticlassScope);
3436
3451
}
3437
3452
@@ -3623,7 +3638,7 @@ bool TGParser::ParseFile() {
3623
3638
if (Lex.getCode () == tgtok::Eof)
3624
3639
return false ;
3625
3640
3626
- return TokError (" Unexpected input at top level" );
3641
+ return TokError (" Unexpected token at top level" );
3627
3642
}
3628
3643
3629
3644
// Check an assertion: Obtain the condition value and be sure it is true.
0 commit comments