When skipping a macro definintion because of an error, apply the same handling
regarding .endmacro as when the macro is parsed regularily: A .endmacro ends the macro only if is the first token on a line.
This commit is contained in:
@@ -373,20 +373,22 @@ static void MacSkipDef (unsigned Style, const FilePos* StartPos)
|
|||||||
/* Skip a macro definition */
|
/* Skip a macro definition */
|
||||||
{
|
{
|
||||||
if (Style == MAC_STYLE_CLASSIC) {
|
if (Style == MAC_STYLE_CLASSIC) {
|
||||||
/* Skip tokens until we reach the final .endmacro. Be liberal about
|
/* Skip tokens until we reach the final .endmacro. Implement the same
|
||||||
** .endmacro here since we had errors anyway when this function is
|
** behavior as when parsing the macro regularily: .endmacro needs to
|
||||||
** called.
|
** be at the start of the line to end the macro definition.
|
||||||
*/
|
*/
|
||||||
|
int LastWasSep = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (CurTok.Tok == TOK_EOF) {
|
if (CurTok.Tok == TOK_EOF) {
|
||||||
ErrorExpect ("Expected '.ENDMACRO'");
|
ErrorExpect ("Expected '.ENDMACRO'");
|
||||||
PNotification (StartPos, "Macro definition started here");
|
PNotification (StartPos, "Macro definition started here");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (CurTok.Tok == TOK_ENDMACRO) {
|
if (CurTok.Tok == TOK_ENDMACRO && LastWasSep) {
|
||||||
NextTok ();
|
NextTok ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
LastWasSep = (CurTok.Tok == TOK_SEP);
|
||||||
NextTok ();
|
NextTok ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
6
test/asm/listing/142-errormsg.s
Normal file
6
test/asm/listing/142-errormsg.s
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.macro mac
|
||||||
|
.define endmac .endmacro
|
||||||
|
.endmacro
|
||||||
|
.macro mac
|
||||||
|
.define endmac .endmacro
|
||||||
|
.endmacro
|
||||||
2
test/asm/listing/ref/142-errormsg.err2
Normal file
2
test/asm/listing/ref/142-errormsg.err2
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
142-errormsg.s:4: Error: A macro named 'mac' is already defined
|
||||||
|
142-errormsg.s:1: Note: Previous definition of macro 'mac' was here
|
||||||
Reference in New Issue
Block a user