summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor van den Elzen <victor.vde@gmail.com>2008-07-23 15:14:22 +0200
committerVictor van den Elzen <victor.vde@gmail.com>2008-07-23 15:14:22 +0200
commitb916edecf427058f2345846075a382cb27bfbd75 (patch)
tree50d5a606c5b0f434dbbaf9bdc8e532e97f6be31f
parent0e857f1fe5368ceb014ec1cb6f5bdb056c982547 (diff)
downloadnasm-b916edecf427058f2345846075a382cb27bfbd75.tar.gz
BR 560960: warn about trailing garbage in %macro/%ifmacro
-rw-r--r--preproc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/preproc.c b/preproc.c
index 39aa2abf..9f520c3f 100644
--- a/preproc.c
+++ b/preproc.c
@@ -1647,6 +1647,8 @@ static bool if_condition(Token * tline, enum preproc_token ct)
}
mmac = mmac->next;
}
+ if(tline && tline->next)
+ error(ERR_WARNING, "trailing garbage after %%ifmacro ignored");
nasm_free(searching.name);
j = found;
break;
@@ -1817,16 +1819,19 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
error(ERR_NONFATAL, "`%s' expects a macro name", directive);
return false;
}
+
def->name = nasm_strdup(tline->text);
def->plus = false;
def->nolist = false;
def->in_progress = 0;
def->rep_nest = NULL;
+ def->nparam_min = 0;
+ def->nparam_max = 0;
+
tline = expand_smacro(tline->next);
skip_white_(tline);
if (!tok_type_(tline, TOK_NUMBER)) {
error(ERR_NONFATAL, "`%s' expects a parameter count", directive);
- def->nparam_min = def->nparam_max = 0;
} else {
def->nparam_min = def->nparam_max =
readnum(tline->text, &err);
@@ -1875,6 +1880,9 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
}
def->expansion = NULL;
+ if(def->defaults && def->ndefs > def->nparam_max - def->nparam_min)
+ error(ERR_WARNING, "too much default macro parameters");
+
return true;
}