public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RFC: gas .warning "msg" and .error "msg" directives?
@ 2004-11-03  3:01 Hans-Peter Nilsson
  2004-11-03  6:47 ` Ken Raeburn
  0 siblings, 1 reply; 4+ messages in thread
From: Hans-Peter Nilsson @ 2004-11-03  3:01 UTC (permalink / raw)
  To: binutils

How about .error and .warning directives, matching the following
texinfo snippet?  In contrast to .err or just using an undefined
pseudo, this allows the programmer to specify the output,
similar to #warn and #error in cpp.

+`.error STRING'
+     This directive emits an error with the message STRING.  If you
+     don't specify STRING, it defaults to `"(unspecified)"'.
+
+           .error "This code has not been assembled and tested."
+
+`.warning STRING'
+     Similar to the directive `.error', but just emits a warning.
+

The incredibly intricate code would look something like this
(snippets from currently port-local implementation provided for
discussion only, not indented for approval - though preapproval
would of course be welcome):

+  {"error", s_cris_errwarn, 1},
+  {"warning", s_cris_errwarn, 0},

+/* Emit an error or a warning.  */
+
+static void
+s_cris_errwarn (err)
+     int err;
+{
+  char *msg = _("(unspecified)");
+  int len;
+
+  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 ();
+}

If not, I'll pout and keep them local to the CRIS port.

brgds, H-P
PS.  I have a test-suite too, of course. ;-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC: gas .warning "msg" and .error "msg" directives?
  2004-11-03  3:01 RFC: gas .warning "msg" and .error "msg" directives? Hans-Peter Nilsson
@ 2004-11-03  6:47 ` Ken Raeburn
  2004-11-03 14:19   ` Hans-Peter Nilsson
  0 siblings, 1 reply; 4+ messages in thread
From: Ken Raeburn @ 2004-11-03  6:47 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

On Nov 2, 2004, at 22:01, Hans-Peter Nilsson wrote:
> How about .error and .warning directives, matching the following
> texinfo snippet?  In contrast to .err or just using an undefined
> pseudo, this allows the programmer to specify the output,
> similar to #warn and #error in cpp.
>
> +`.error STRING'
> +     This directive emits an error with the message STRING.  If you
> +     don't specify STRING, it defaults to `"(unspecified)"'.

Why not make it default to something that actually describes the 
situation, e.g., ".error directive invoked in source file".  
Conceptually, you could also make the message be required -- for .error 
that just means you print a slightly different message if it's omitted 
("missing .error parameter" for example), the practical difference is 
whether .warning without a message would be an error or not. :-)

Ken

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC: gas .warning "msg" and .error "msg" directives?
  2004-11-03  6:47 ` Ken Raeburn
@ 2004-11-03 14:19   ` Hans-Peter Nilsson
  2004-11-03 15:26     ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Hans-Peter Nilsson @ 2004-11-03 14:19 UTC (permalink / raw)
  To: raeburn; +Cc: hans-peter.nilsson, binutils

> From: Ken Raeburn <raeburn@raeburn.org>
> Date: Wed, 3 Nov 2004 01:47:10 -0500

> Why not make it default to something that actually describes the 
> situation, e.g., ".error directive invoked in source file".  
> Conceptually, you could also make the message be required -- for .error 
> that just means you print a slightly different message if it's omitted 
> ("missing .error parameter" for example), the practical difference is 
> whether .warning without a message would be an error or not. :-)

All valid points.  Consider them merged with my suggestion, with:
An .error without a string should be compatible with ".err" and
just emit ".error directive invoked in source file".  A .warning
should just warn, with the default message being...you guessed
it ".warning directive invoked in source file".

brgds, H-P

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC: gas .warning "msg" and .error "msg" directives?
  2004-11-03 14:19   ` Hans-Peter Nilsson
@ 2004-11-03 15:26     ` Nick Clifton
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2004-11-03 15:26 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: raeburn, binutils

Hi Hans-Peter,

>>Why not make it default to something that actually describes the 
>>situation, e.g., ".error directive invoked in source file".  
>>Conceptually, you could also make the message be required -- for .error 
>>that just means you print a slightly different message if it's omitted 
>>("missing .error parameter" for example), the practical difference is 
>>whether .warning without a message would be an error or not. :-)
> 
> 
> All valid points.  Consider them merged with my suggestion, with:
> An .error without a string should be compatible with ".err" and
> just emit ".error directive invoked in source file".  A .warning
> should just warn, with the default message being...you guessed
> it ".warning directive invoked in source file".

Ok - if you would care to post a patch like that, along with a case or 
two for the testsuite then I would be happy to review it.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-03 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-03  3:01 RFC: gas .warning "msg" and .error "msg" directives? Hans-Peter Nilsson
2004-11-03  6:47 ` Ken Raeburn
2004-11-03 14:19   ` Hans-Peter Nilsson
2004-11-03 15:26     ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).