[m-rev.] for review: disable_warning [unknown_format_calls]
Julien Fischer
jfischer at opturion.com
Wed Sep 7 16:45:35 AEST 2022
On Wed, 7 Sep 2022, Zoltan Somogyi wrote:
> On Wed, 24 Aug 2022 16:36:55 +1000 (AEST), "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> Attached is the second part of this change, which uses
> the new capability. For post-commit review by anyone.
> Note that the diff updates configure.ac to require a compiler
> with the first half of this change, which was committed
> aug 24.
...
> Disable unknown_format_call warnings using scopes.
>
> configure.ac:
> Require the installed compiler to support disable_warning scopes
> for unknown_format_calls.
>
> compiler/Mercury.options:
> library/Mercury.options:
> Do not disable unknown_format_call warnings in whole files.
>
> compiler/parse_tree_out_info.m:
> compiler/pd_debug.m:
> library/io.m:
> library/stream.string_writer.m:
> library/string.m:
> Disable unknown_format_call warnings for just the format calls
> that need it.
...
> diff --git a/compiler/pd_debug.m b/compiler/pd_debug.m
> index 2c4bb1eb7..d6c983556 100644
> --- a/compiler/pd_debug.m
> +++ b/compiler/pd_debug.m
> @@ -87,7 +87,9 @@ pd_debug_message(PDInfo, Fmt, Args, !IO) :-
> DebugPD = yes,
> module_info_get_name(ModuleInfo, ModuleName),
> get_debug_output_stream(Globals, ModuleName, Stream, !IO),
> - io.format(Stream, Fmt, Args, !IO),
> + disable_warning [unknown_format_calls] (
> + io.format(Stream, Fmt, Args, !IO)
> + ),
> io.flush_output(Stream, !IO)
> ).
Unrelated: is it feasible to extend the checking done by compiler/format_call.m
to check wrappers around io.format etc. like pd_debug_message? For example,
if we add a pragma like:
:- pragma check_format_call(pred(pd_debug_message/5), [format_args(2, 3)]).
where format_args(2, 3) identifies the arguments containing the format string
and its corresponding list of poly_types. (GCC supports a function attribute
that does something similar for printf()).
This diff looks fine.
Julien.
More information about the reviews
mailing list