mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
This implements Mantis feature request #497. compiler/parse_goal.m: compiler/parse_dcg_goal.m: When we find that a disable_warnings scope contains an unrecognized warning name, generate a warning for it, and return this warning *alongside*, not *instead of*, the disable_warnings scope goal. This requires passing around not a maybe1(goal), as we have been doing till now, but a maybe2(goal, list(warning_spec)), so this change affects both (1) most of these two modules, and (2) most of the modules below. compiler/error_util.m: Provide warning_spec as a synonym for error_spec, to be used in situations like this where the "error_spec" is intended contain something with severity_warning. compiler/maybe_error.m: Provide some new utility predicates now needed in parse_goal.m and elsewhere. compiler/prog_item.m: Provide room in the representation of clauses for the warnings generated by parsing the clause body goal. compiler/add_class.m: compiler/add_clause.m: compiler/add_mutable_aux_preds.m: compiler/add_pragma_tabling.m: compiler/du_type_layout.m: compiler/get_dependencies.m: compiler/make_hlds_passes.m: compiler/parse_item.m: compiler/parse_tree_out_clause.m: compiler/prog_item_stats.m: compiler/superhomogeneous.m: Conform to the changes above. tests/valid/unknown_warning.m: Add this test case that checks whether a source file with an unknown warning name in a disable_warnings scope can have code generated for it. tests/warnings/unknown_warning.{m,exp}: Add the same source file to this directory as well, to check whether we get the right set of warnings. tests/valid/Mmakefile: tests/valid/Mercury.options: tests/warnings/Mmakefile: Enable the two new test cases.
28 lines
785 B
Mathematica
28 lines
785 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This tests that an unknown warning name in a disable_warnings scope
|
|
% does not prevent the compiler from generating target language code.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module unknown_warning.
|
|
:- interface.
|
|
|
|
:- pred unknown_warning(int::in, int::in, int::out) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
|
|
unknown_warning(A, B, X) :-
|
|
disable_warning [singleton_varx]
|
|
(
|
|
C = A + B,
|
|
D = A - B, % D is a singleton
|
|
X = C
|
|
).
|