[PATCH v1] gas: add as_info() for informational diagnostics

Jan Beulich jbeulich@suse.com
Tue Dec 23 07:36:01 GMT 2025


On 22.12.2025 18:03, Matthieu Longo wrote:
> This patch adds as_info(), the informational counterpart of as_warn()
> and as_bad().

I wouldn't have put it like this, as we have as_info_where() already (which
is at least as close a sibling). This in particular reflects ...

> --- a/gas/messages.c
> +++ b/gas/messages.c
> @@ -127,6 +127,45 @@ as_show_where (void)
>      }
>  }
>  
> +/* The common portion of as_info, and as_info_where.  */
> +
> +static void
> +as_info_internal (const char *file, unsigned int line, unsigned int indent,
> +		  const char *buffer)
> +{
> +  if (file == NULL)
> +    file = as_where_top (&line);
> +
> +  if (file)
> +    {
> +      if (line != 0)
> +	fprintf (stderr, "%s:%u: %*s%s%s\n",
> +		 file, line, (int)indent, "", _("Info: "), buffer);
> +      else
> +	fprintf (stderr, "%s: %s%s\n", file, _("Info: "), buffer);
> +    }
> +  else
> +    fprintf (stderr, "%s%s\n", _("Info: "), buffer);
> +}
> +
> +/* Send to stderr a string as a information, and locate information
> +   in input file(s).  */
> +
> +void
> +as_info (const char *format, ...)
> +{
> +  if (flag_no_information)
> +    return;
> +
> +  va_list args;
> +  char buffer[2000];
> +
> +  va_start (args, format);
> +  vsnprintf (buffer, sizeof (buffer), format, args);
> +  va_end (args);
> +  as_info_internal (NULL, 0, 0, buffer);

... here, where you omit the "indent" parameter, passing 0 instead as an
argument to the internal helper. Like for the present uses of
as_info_where(), in cases where as_info() is used to expand on an earlier
as_warn() or as_bad() (i.e. the use case you also have), imo "indent"
should never be 0. It may be 0 for as completely standalone as_info().
(For for your use case in principle you could have use as_info_where(),
and then I would also have asked to pass a non-zero value for "indent".)

IOW: Okay with it being

void
as_info (unsigned int indent, const char *format, ...)

Jan


More information about the Binutils mailing list