This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: gas .warning "msg" and .error "msg" directives?


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. ;-)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]