mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
BR 3392668: preproc: test for macro in TOK_LOCAL_SYMBOL
TOK_LOCAL_SYMBOL is only applicable inside a macro; otherwise error out just like we do for TOK_MMACRO_PARAM. This *partially* addresses BR 3392668. Reported-by: <puppet@zju.edu.cn> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
@@ -4756,6 +4756,7 @@ static Token *expand_mmac_params(Token * tline)
|
|||||||
|
|
||||||
while (tline) {
|
while (tline) {
|
||||||
bool change;
|
bool change;
|
||||||
|
bool err_not_mac = false;
|
||||||
Token *t = tline;
|
Token *t = tline;
|
||||||
const char *text = tok_text(t);
|
const char *text = tok_text(t);
|
||||||
int type = t->type;
|
int type = t->type;
|
||||||
@@ -4765,9 +4766,15 @@ static Token *expand_mmac_params(Token * tline)
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TOK_LOCAL_SYMBOL:
|
case TOK_LOCAL_SYMBOL:
|
||||||
|
change = true;
|
||||||
|
|
||||||
|
if (!mac) {
|
||||||
|
err_not_mac = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
type = TOK_ID;
|
type = TOK_ID;
|
||||||
text = nasm_asprintf("..@%"PRIu64".%s", mac->unique, text+2);
|
text = nasm_asprintf("..@%"PRIu64".%s", mac->unique, text+2);
|
||||||
change = true;
|
|
||||||
break;
|
break;
|
||||||
case TOK_MMACRO_PARAM:
|
case TOK_MMACRO_PARAM:
|
||||||
{
|
{
|
||||||
@@ -4776,8 +4783,7 @@ static Token *expand_mmac_params(Token * tline)
|
|||||||
change = true;
|
change = true;
|
||||||
|
|
||||||
if (!mac) {
|
if (!mac) {
|
||||||
nasm_nonfatal("`%s': not in a macro call", text);
|
err_not_mac = true;
|
||||||
text = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4910,6 +4916,12 @@ static Token *expand_mmac_params(Token * tline)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (err_not_mac) {
|
||||||
|
nasm_nonfatal("`%s': not in a macro call", text);
|
||||||
|
text = NULL;
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (change) {
|
if (change) {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
delete_Token(t);
|
delete_Token(t);
|
||||||
|
BIN
test/br3392668-3.asm
Normal file
BIN
test/br3392668-3.asm
Normal file
Binary file not shown.
Reference in New Issue
Block a user