Files
mercury/compiler/maybe_error.m
Zoltan Somogyi 4f32c50822 Let clauses with unknown warnings be processed.
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.
2020-04-05 19:09:31 +10:00

99 lines
3.1 KiB
Mathematica

%-----------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2015 The Mercury team.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
:- module parse_tree.maybe_error.
:- interface.
:- import_module parse_tree.error_util.
:- import_module list.
%-----------------------------------------------------------------------------%
:- type maybe_safe_to_continue
---> safe_to_continue
; unsafe_to_continue.
%-----------------------------------------------------------------------------%
:- type maybe1(T1)
---> error1(list(error_spec))
; ok1(T1).
:- type maybe2(T1, T2)
---> error2(list(error_spec))
; ok2(T1, T2).
:- type maybe3(T1, T2, T3)
---> error3(list(error_spec))
; ok3(T1, T2, T3).
:- type maybe4(T1, T2, T3, T4)
---> error4(list(error_spec))
; ok4(T1, T2, T3, T4).
:- inst maybe1(I) for maybe1/1
---> error1(ground)
; ok1(I).
:- inst maybe2(I1, I2) for maybe2/2
---> error2(ground)
; ok2(I1, I2).
:- inst maybe3(I1, I2, I3) for maybe3/3
---> error3(ground)
; ok3(I1, I2, I3).
:- inst maybe4(I1, I2, I3, I4) for maybe4/4
---> error4(ground)
; ok4(I1, I2, I3, I4).
:- func get_any_errors1(maybe1(T1)) = list(error_spec).
:- func get_any_errors2(maybe2(T1, T2)) = list(error_spec).
:- func get_any_errors3(maybe3(T1, T2, T3)) = list(error_spec).
:- func get_any_errors4(maybe4(T1, T2, T3, T4)) = list(error_spec).
:- func get_any_errors_warnings2(maybe2(T1, list(warning_spec))) =
list(error_spec).
:- func get_any_errors_warnings3(maybe3(T1, T2, list(warning_spec))) =
list(error_spec).
:- func get_any_errors_warnings4(maybe4(T1, T2, T3, list(warning_spec))) =
list(error_spec).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
%-----------------------------------------------------------------------------%
get_any_errors1(ok1(_)) = [].
get_any_errors1(error1(Specs)) = Specs.
get_any_errors2(ok2(_, _)) = [].
get_any_errors2(error2(Specs)) = Specs.
get_any_errors3(ok3(_, _, _)) = [].
get_any_errors3(error3(Specs)) = Specs.
get_any_errors4(ok4(_, _, _, _)) = [].
get_any_errors4(error4(Specs)) = Specs.
get_any_errors_warnings2(ok2(_, Specs)) = Specs.
get_any_errors_warnings2(error2(Specs)) = Specs.
get_any_errors_warnings3(ok3(_, _, Specs)) = Specs.
get_any_errors_warnings3(error3(Specs)) = Specs.
get_any_errors_warnings4(ok4(_, _, _, Specs)) = Specs.
get_any_errors_warnings4(error4(Specs)) = Specs.
%-----------------------------------------------------------------------------%
:- end_module parse_tree.maybe_error.
%-----------------------------------------------------------------------------%