This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[RFA:] .error "msg" and .warning "msg" directives.
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 4 Nov 2004 02:58:18 +0100
- Subject: [RFA:] .error "msg" and .warning "msg" directives.
No objections, so here goes. Tested native i686-pc-linux-gnu
and cross to cris-axis-elf. Of significance is that ";#" is
used in the testsuite as a universally compatible comment
delimiter for the dejagnu directives (same as gcc uses by
default). I also ran "make info" and inspected result of "make
dvi". At first I put the dg-test in a separate gas/all/dg.exp,
but tripped over a bug in dejagnu-1.4.4, expect-5.39.0. or the
testsuite framework: you can't run a dg-* test as the first
test; it will fail with the following message:
Running /home/hp/binutils2/src/gas/testsuite/gas/all/dg.exp ...
send: spawn id exp0 not open
while executing
"send_user "$message\n""
("default" arm line 2)
invoked from within
"case "$firstword" in {
{"PASS:" "XFAIL:" "KFAIL:" "UNRESOLVED:" "UNSUPPORTED:" "UNTESTED:"} {
if $all_flag {
send_user "$message\n"
return "..."
(procedure "clone_output" line 10)
invoked from within
"clone_output "Running $test_file_name ...""
(procedure "runtest" line 9)
invoked from within
"runtest $test_name"
("foreach" body line 42)
invoked from within
"foreach test_name [lsort [find ${dir} *.exp]] {
if { ${test_name} == "" } {
continue
}
# Ignore this one if asked to.
if { ${ignore..."
("foreach" body line 54)
invoked from within
"foreach dir "${test_top_dirs}" {
if { ${dir} != ${srcdir} } {
# Ignore this directory if is a directory to be
# ignored.
if {[info..."
("foreach" body line 121)
invoked from within
"foreach pass $multipass {
# multipass_name is set for `record_test' to use (see framework.exp).
if { [lindex $pass 0] != "" } {
set multipass_..."
("foreach" body line 51)
invoked from within
"foreach current_target $target_list {
verbose "target is $current_target"
set current_target_name $current_target
set tlist [split $curren..."
(file "/usr/share/dejagnu/runtest.exp" line 1625)
Please forgive me for masking this problem by just adding the dg-tests
to the end of all.exp. (It works to call the file e.g. zdg.exp as
well, just as long as *some* other test has run before it. ;-)
(Ben or other DejaGuru, please help!)
Ok to commit?
gas:
* 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/testsuite:
* gas/all/gas.exp: Run dg-runtest for all err-*.s and warn-*.s
* gas/all/err-1.s, gas/all/warn-1.s: New tests.
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.79
diff -p -c -r1.79 read.c
*** gas/read.c 13 Aug 2004 19:53:51 -0000 1.79
--- gas/read.c 4 Nov 2004 01:34:42 -0000
*************** static const pseudo_typeS potable[] = {
*** 306,311 ****
--- 306,312 ----
{"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. */
*************** static const pseudo_typeS potable[] = {
*** 411,416 ****
--- 412,418 ----
{"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. */
*************** s_err (int ignore ATTRIBUTE_UNUSED)
*** 1665,1670 ****
--- 1667,1706 ----
demand_empty_rest_of_line ();
}
+ /* Handle the .error and .warning pseudo-ops. */
+
+ void
+ s_errwarn (int err)
+ {
+ int len;
+ 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 != '\"')
+ {
+ msg = err
+ ? _(".error argument must be a string")
+ : _(".warning argument must be a string");
+ as_bad (msg);
+ discard_rest_of_line ();
+ return;
+ }
+
+ msg = demand_copy_C_string (&len);
+ if (msg == NULL)
+ return;
+ }
+
+ if (err)
+ as_bad (msg);
+ else
+ as_warn (msg);
+ demand_empty_rest_of_line ();
+ }
+
/* Handle the MRI fail pseudo-op. */
void
Index: gas/read.h
===================================================================
RCS file: /cvs/src/src/gas/read.h,v
retrieving revision 1.23
diff -p -c -r1.23 read.h
*** gas/read.h 9 Feb 2004 12:12:42 -0000 1.23
--- gas/read.h 4 Nov 2004 01:34:42 -0000
*************** extern void s_elseif (int arg);
*** 151,156 ****
--- 151,157 ----
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);
Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.107
diff -p -c -r1.107 as.texinfo
*** gas/doc/as.texinfo 11 Oct 2004 16:39:34 -0000 1.107
--- gas/doc/as.texinfo 4 Nov 2004 01:34:47 -0000
*************** Some machine configurations provide addi
*** 3724,3729 ****
--- 3724,3730 ----
* 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}
*************** Some machine configurations provide addi
*** 3840,3845 ****
--- 3841,3847 ----
* 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
*************** If @command{@value{AS}} assembles a @cod
*** 4238,4243 ****
--- 4240,4258 ----
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}.
*************** parent whose addend is the value of the
*** 5863,5868 ****
--- 5878,5889 ----
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}}
Index: gas/testsuite/gas/all/gas.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/gas.exp,v
retrieving revision 1.21
diff -p -c -r1.21 gas.exp
*** gas/testsuite/gas/all/gas.exp 25 Aug 2004 17:05:10 -0000 1.21
--- gas/testsuite/gas/all/gas.exp 4 Nov 2004 01:34:47 -0000
*************** if { [istarget "i*86-*-*pe*"] \
*** 194,196 ****
--- 194,201 ----
|| [istarget "i*86-*-mingw32*"] } {
gas_test "fastcall.s" "" "" "fastcall labels"
}
+
+ load_lib gas-dg.exp
+ dg-init
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
+ dg-finish
--- /dev/null 2004-02-23 22:02:56.000000000 +0100
+++ err-1.s 2004-11-04 01:50:27.988776999 +0100
@@ -0,0 +1,7 @@
+;# Test .error directive.
+;# { dg-do assemble }
+ .error "an error message" ;# { dg-error "Error: an error message" }
+ .error an error message ;# { dg-error "Error: .error argument must be a string" }
+ .error ;# { dg-error "Error: .error directive invoked in source file" }
+ .error ".error directive invoked in source file" ;# { dg-error "Error: .error directive invoked in source file" }
+ .error "" ;# { dg-error "Error: " }
--- /dev/null 2004-02-23 22:02:56.000000000 +0100
+++ warn-1.s 2004-11-04 01:50:02.837532208 +0100
@@ -0,0 +1,7 @@
+;# Test .warning directive.
+;# { dg-do assemble }
+ .warning "a warning message" ;# { dg-warning "Warning: a warning message" }
+ .warning a warning message ;# { dg-error "Error: .warning argument must be a string" }
+ .warning ;# { dg-warning "Warning: .warning directive invoked in source file" }
+ .warning ".warning directive invoked in source file" ;# { dg-warning "Warning: .warning directive invoked in source file" }
+ .warning "" ;# { dg-warning "Warning: " }
brgds, H-P