[m-rev.] for review: mode-specific unused arg warnings

Julien Fischer jfischer at opturion.com
Fri Feb 27 21:24:35 AEDT 2026


On Fri, 27 Feb 2026 at 20:50, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:

>
> By the way, do any of you guys ever run the test cases using mmc --make
> *in C grades*?

No.  I seem to recall that it did not work last I tried it.

> The reason I ask is that the warnings/unused_args_analysis
> test case is enabled ONLY with mmc --make, but it is also DISABLED in
> java and C# grades. As far as I can tell, it has not been executed in a long time,
> because its non-colorized expected output files would cause any execution
> to fail.
> Generate mode-specific unused args warnings if needed.
>
> compiler/unused_args_warn_pragma.m:
>     The existing code processed only the first procedure of each predicate,
>     skipping all the later procedures. It had a comment saying that it
>     warns about an unused arg only if it was unused in all modes,
>     but this claim was false.
>
>     Replace this old code with new code that
>
>     - gathers the set of unused args in each procedure, recording
>       which ones have mode "unused",
>
>     - considers all the procedures of a predicate together, and then
>
>     - generates either a single warning for the predicate as a whole,
>       or separate warnings for each procedure that has unused arguments.
>
>     We now generate a single warning for the predicate only if all the
>     procedures agree both on which arguments are unused, and on
>     which of those are *marked* by the mode as unused. Of course,
>     most of the time this will be the case simply because most predicates
>     have just one procedure.
>
>     Stop module qualifying predicate names in the warnings we generate,
>     since we do not generate warnings for imported predicates.
>
>     Color the unqualified name as the subject of the diagnostic.
>
>     When reporting unused args, list the arguments with "unused" modes
>     separately from the other arguments.
>
>     Simplify the interface with our caller in unused_args.m.
>
> compiler/unused_args.m:
>     Conform to the simplified interface with unused_args_warn_pragma.m.
>
> compiler/hlds_error_util.m:
>     Add a new version of an existing utility function.
>
> tests/warnings/unused_args_some_modes.{m,err_exp}:
>     Add a test case for the new capability.
>
> tests/warnings/Mmakefile:
>     Enable the new test case.
>
>     Stop mixing "VAR = VALUE" and "Var += VALUE" definitions
>     of make variables. Give some make variables better names.
>
>     Move some dependency definitions out of a block of rules.
>
> tests/warnings/Mercury.options:
>     Enable --warn-unused args for the new test case.

Missing a hyphen between unused and args there.

That looks fine otherwise.

Julien.


More information about the reviews mailing list