+2005-01-31 Jan Beulich <jbeulich@novell.com>
+
+ * macro.c (do_formals): Adjust to no longer accept empty parameter
+ names.
+ (define_macro): Adjust to no longer accept empty macro name, garbage
+ following the parameters, or macros that were previously defined.
+ * read.c (s_bad_end): Declare.
+ (potable): Add endm. Handler for endr and endm is s_bad_end.
+ (s_bad_end): Rename from s_bad_endr. Adjust to handle both .endm
+ and .endr.
+ * read.h (s_bad_endr): Remove.
+
2005-01-31 Jan Beulich <jbeulich@novell.com>
* config/tc-ia64.c (parse_operands): Parse all specified operands,
macro->formal_count = 0;
macro->formal_hash = hash_new ();
+ idx = sb_skip_white (idx, in);
while (idx < in->len)
{
formal_entry *formal;
+ int cidx;
formal = (formal_entry *) xmalloc (sizeof (formal_entry));
sb_new (&formal->def);
sb_new (&formal->actual);
- idx = sb_skip_white (idx, in);
idx = get_token (idx, in, &formal->name);
if (formal->name.len == 0)
- break;
+ {
+ if (macro->formal_count)
+ --idx;
+ break;
+ }
idx = sb_skip_white (idx, in);
- if (formal->name.len)
+ /* This is a formal. */
+ if (idx < in->len && in->ptr[idx] == '=')
{
- /* This is a formal. */
- if (idx < in->len && in->ptr[idx] == '=')
- {
- /* Got a default. */
- idx = get_any_string (idx + 1, in, &formal->def, 1, 0);
- }
+ /* Got a default. */
+ idx = get_any_string (idx + 1, in, &formal->def, 1, 0);
+ idx = sb_skip_white (idx, in);
}
/* Add to macro's hash table. */
hash_jam (macro->formal_hash, sb_terminate (&formal->name), formal);
- formal->index = macro->formal_count;
+ formal->index = macro->formal_count++;
+ cidx = idx;
idx = sb_skip_comma (idx, in);
- macro->formal_count++;
+ if (idx != cidx && idx >= in->len)
+ {
+ idx = cidx;
+ break;
+ }
*p = formal;
p = &formal->next;
*p = NULL;
{
/* It's the label: MACRO (formals,...) sort */
idx = do_formals (macro, idx + 1, in);
- if (in->ptr[idx] != ')')
+ if (idx >= in->len || in->ptr[idx] != ')')
return _("missing ) after formals");
+ idx = sb_skip_white (idx + 1, in);
}
else
{
}
else
{
+ int cidx;
+
idx = get_token (idx, in, &name);
- idx = sb_skip_comma (idx, in);
- idx = do_formals (macro, idx, in);
+ if (name.len == 0)
+ return _("Missing macro name");
+ cidx = sb_skip_white (idx, in);
+ idx = sb_skip_comma (cidx, in);
+ if (idx == cidx || idx < in->len)
+ idx = do_formals (macro, idx, in);
+ else
+ idx = cidx;
}
+ if (idx < in->len)
+ return _("Bad macro parameter list");
/* And stick it in the macro hash table. */
for (idx = 0; idx < name.len; idx++)
name.ptr[idx] = TOLOWER (name.ptr[idx]);
namestr = sb_terminate (&name);
+ if (hash_find (macro_hash, namestr))
+ return _("Macro with this name was already defined");
hash_jam (macro_hash, namestr, (PTR) macro);
macro_defined = 1;
static void do_align (int, char *, int, int);
static void s_align (int, int);
static void s_altmacro (int);
+static void s_bad_end (int);
static int hex_float (int, char *);
static segT get_known_segmented_expression (expressionS * expP);
static void pobegin (void);
{"endc", s_endif, 0},
{"endfunc", s_func, 1},
{"endif", s_endif, 0},
- {"endr", s_bad_endr, 0},
+ {"endm", s_bad_end, 0},
+ {"endr", s_bad_end, 1},
/* endef */
{"equ", s_set, 0},
{"equiv", s_set, 1},
demand_empty_rest_of_line ();
}
-/* Handle the .rept pseudo-op. */
+/* Handle the .endm/.endr pseudo-ops. */
-void
-s_bad_endr (int ignore ATTRIBUTE_UNUSED)
+static void
+s_bad_end (int endr)
{
- as_warn (_(".endr encountered without preceeding .rept, .irc, or .irp"));
+ as_warn (_(".end%c encountered without preceeding %s"),
+ endr ? 'r' : 'm',
+ endr ? ".rept, .irp, or .irpc" : ".macro");
demand_empty_rest_of_line ();
}