BR 560960: warn about trailing garbage in %macro/%ifmacro
authorVictor van den Elzen <victor.vde@gmail.com>
Wed, 23 Jul 2008 13:14:22 +0000 (15:14 +0200)
committerVictor van den Elzen <victor.vde@gmail.com>
Wed, 23 Jul 2008 13:14:22 +0000 (15:14 +0200)
preproc.c

index 39aa2abfacecaa60c9054e7219e72ee2720558bc..9f520c3f973b4a5bef180af312b615346becaf36 100644 (file)
--- 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;
 }