From 7e3e880aa099bb06384dd50188751e24d9de0f70 Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Mon, 22 Nov 2004 13:05:27 +0000 Subject: [PATCH] * read.c (potable): Add "error" and "warning". (s_errwarn): New function. * read.h (s_errwarn): Declare. * doc/as.texinfo (Error, Warning): Document .error and .warning. --- gas/ChangeLog | 7 +++++++ gas/doc/as.texinfo | 21 +++++++++++++++++++++ gas/read.c | 39 +++++++++++++++++++++++++++++++++++++++ gas/read.h | 1 + 4 files changed, 68 insertions(+) diff --git a/gas/ChangeLog b/gas/ChangeLog index a53d39bb75..3272fd7760 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2004-11-22 Hans-Peter Nilsson + + * read.c (potable): Add "error" and "warning". + (s_errwarn): New function. + * read.h (s_errwarn): Declare. + * doc/as.texinfo (Error, Warning): Document .error and .warning. + 2004-11-22 Nick Clifton * config/tc-tic54x.c (tic54x_adjust_symtab): Adjust call to diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 3d4a5ab4ad..b550aa93c0 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -3726,6 +3726,7 @@ Some machine configurations provide additional directives. * Equ:: @code{.equ @var{symbol}, @var{expression}} * Equiv:: @code{.equiv @var{symbol}, @var{expression}} * Err:: @code{.err} +* Error:: @code{.error @var{string}} * Exitm:: @code{.exitm} * Extern:: @code{.extern} * Fail:: @code{.fail} @@ -3842,6 +3843,7 @@ Some machine configurations provide additional directives. * VTableInherit:: @code{.vtable_inherit @var{child}, @var{parent}} @end ifset +* Warning:: @code{.warning @var{string}} * Weak:: @code{.weak @var{names}} * Word:: @code{.word @var{expressions}} * Deprecated:: Deprecated Directives @@ -4240,6 +4242,19 @@ If @command{@value{AS}} assembles a @code{.err} directive, it will print an erro message and, unless the @option{-Z} option was used, it will not generate an object file. This can be used to signal error an conditionally compiled code. +@node Error +@section @code{.error "@var{string}"} +@cindex error directive + +Similarly to @code{.err}, this directive emits an error, but you can specify a +string that will be emitted as the error message. If you don't specify the +message, it defaults to @code{".error directive invoked in source file"}. +@xref{Errors, ,Error and Warning Messages}. + +@smallexample + .error "This code has not been assembled and tested." +@end smallexample + @node Exitm @section @code{.exitm} Exit early from the current macro definition. @xref{Macro}. @@ -5865,6 +5880,12 @@ parent whose addend is the value of the child symbol. As a special case the parent name of @code{0} is treated as refering the @code{*ABS*} section. @end ifset +@node Warning +@section @code{.warning "@var{string}"} +@cindex warning directive +Similar to the directive @code{.error} +(@pxref{Error,,@code{.error "@var{string}"}}), but just emits a warning. + @node Weak @section @code{.weak @var{names}} diff --git a/gas/read.c b/gas/read.c index 00fd38a340..d0bf2c1fd1 100644 --- a/gas/read.c +++ b/gas/read.c @@ -306,6 +306,7 @@ static const pseudo_typeS potable[] = { {"equ", s_set, 0}, {"equiv", s_set, 1}, {"err", s_err, 0}, + {"error", s_errwarn, 1}, {"exitm", s_mexit, 0}, /* extend */ {"extern", s_ignore, 0}, /* We treat all undef as ext. */ @@ -411,6 +412,7 @@ static const pseudo_typeS potable[] = { {"xdef", s_globl, 0}, {"xref", s_ignore, 0}, {"xstabs", s_xstab, 's'}, + {"warning", s_errwarn, 0}, {"word", cons, 2}, {"zero", s_space, 0}, {NULL, NULL, 0} /* End sentinel. */ @@ -1665,6 +1667,43 @@ s_err (int ignore ATTRIBUTE_UNUSED) demand_empty_rest_of_line (); } +/* Handle the .error and .warning pseudo-ops. */ + +void +s_errwarn (int err) +{ + int len; + /* The purpose for the conditional assignment is not to + internationalize the directive itself, but that we need a + self-contained message, one that can be passed like the + demand_copy_C_string return value, and with no assumption on the + location of the name of the directive within the message. */ + char *msg + = (err ? _(".error directive invoked in source file") + : _(".warning directive invoked in source file")); + + if (!is_it_end_of_statement ()) + { + if (*input_line_pointer != '\"') + { + as_bad (_("%s argument must be a string"), + err ? ".error" : ".warning"); + discard_rest_of_line (); + return; + } + + msg = demand_copy_C_string (&len); + if (msg == NULL) + return; + } + + if (err) + as_bad ("%s", msg); + else + as_warn ("%s", msg); + demand_empty_rest_of_line (); +} + /* Handle the MRI fail pseudo-op. */ void diff --git a/gas/read.h b/gas/read.h index 35c810b990..10acef9622 100644 --- a/gas/read.h +++ b/gas/read.h @@ -151,6 +151,7 @@ extern void s_elseif (int arg); extern void s_end (int arg); extern void s_endif (int arg); extern void s_err (int); +extern void s_errwarn (int); extern void s_fail (int); extern void s_fill (int); extern void s_float_space (int mult); -- 2.11.0