diff --git a/compiler/add_pragma_decl.m b/compiler/add_pragma_decl.m index f2219e358..fc308262c 100644 --- a/compiler/add_pragma_decl.m +++ b/compiler/add_pragma_decl.m @@ -154,9 +154,8 @@ add_decl_pragmas_type_spec([Pragma | Pragmas], !ModuleInfo, !QualInfo, add_decl_pragmas_input_mode_spec([], !ModuleInfo, !ErrSpecsWarnSpecs). add_decl_pragmas_input_mode_spec([ImsList | ImsLists], !ModuleInfo, !ErrSpecs) :- - ImsList = ims_sub_list(ItemMercuryStatus, Pragmas), - list.foldl2(add_pragma_input_mode_spec(ItemMercuryStatus), Pragmas, - !ModuleInfo, !ErrSpecs), + ImsList = ims_sub_list(_ItemMercuryStatus, Pragmas), + list.foldl2(add_pragma_input_mode_spec, Pragmas, !ModuleInfo, !ErrSpecs), add_decl_pragmas_input_mode_spec(ImsLists, !ModuleInfo, !ErrSpecs). add_decl_pragmas_termination([], !ModuleInfo, !ErrSpecs). @@ -212,8 +211,7 @@ add_decl_pragma(ProgressStream, ItemMercuryStatus, Pragma, !ErrSpecs, !WarnSpecs) ; Pragma = decl_pragma_input_mode_spec(InputSpecInfo), - add_pragma_input_mode_spec(ItemMercuryStatus, InputSpecInfo, - !ModuleInfo, !ErrSpecs) + add_pragma_input_mode_spec(InputSpecInfo, !ModuleInfo, !ErrSpecs) ; Pragma = decl_pragma_oisu(OISUInfo), add_pragma_oisu(OISUInfo, ItemMercuryStatus, !ModuleInfo, !ErrSpecs) @@ -393,12 +391,11 @@ mark_pred_as_format_call(FormatCallInfo, PragmaStatus, !ModuleInfo, %---------------------% -:- pred add_pragma_input_mode_spec(item_mercury_status::in, - decl_pragma_input_mode_spec_info::in, module_info::in, module_info::out, +:- pred add_pragma_input_mode_spec(decl_pragma_input_mode_spec_info::in, + module_info::in, module_info::out, list(err_spec)::in, list(err_spec)::out) is det. -add_pragma_input_mode_spec(ItemMercuryStatus, InputSpec, - !ModuleInfo, !ErrSpecs) :- +add_pragma_input_mode_spec(InputSpec, !ModuleInfo, !ErrSpecs) :- % XXX If we ever want to get smart recompilation working, we may % have to do something with _RecompIds. What we do for type_spec pragmas % may, or may not, be appropriate for input spec pragmas as well. @@ -407,35 +404,6 @@ add_pragma_input_mode_spec(ItemMercuryStatus, InputSpec, TVarSet, Context, _), some [!InputSpecs] ( !:InputSpecs = [], - ( - ItemMercuryStatus = item_defined_in_other_module(_) - ; - ItemMercuryStatus = item_defined_in_this_module(ItemExport), - ( - ItemExport = item_export_anywhere, - ( - ReplaceOrAdd = replace_in_mode, - StatusPieces = [words("Error: a"), - pragma_decl("input_mode_spec"), words("declaration"), - words("that occurs in the interface of its module"), - words("is not allowed to specify")] ++ - color_as_incorrect([words("replace_in_mode,")]) ++ - [words("as this would contradict"), - words("the mode declarations of the"), - words("predicates and/or functions"), - words("in its public interface."), nl], - StatusSpec = spec($pred, severity_error, phase_pt2h, - Context, StatusPieces), - !:InputSpecs = [StatusSpec | !.InputSpecs] - ; - ReplaceOrAdd = add_to_in_mode - ) - ; - ( ItemExport = item_export_nowhere - ; ItemExport = item_export_only_submodules - ) - ) - ), module_info_get_type_table(!.ModuleInfo, TypeTable), check_input_mode_spec_type(TypeTable, Type, [], UnknownTypeCtors, [], NonDuTypeCtors, bag.init, TVars), diff --git a/compiler/mercury_compile_front_end.m b/compiler/mercury_compile_front_end.m index 53c328c8e..b5b92a4ab 100644 --- a/compiler/mercury_compile_front_end.m +++ b/compiler/mercury_compile_front_end.m @@ -1493,7 +1493,15 @@ simplify_pred(ProgressStream, SimplifyTasks0, PredId, ), PredSpecsAcc0 = init_diag_spec_accumulator, simplify_pred_procs(ProgressStream, SimplifyTasks, PredId, ProcIds, - !PredInfo, !ModuleInfo, PredSpecsAcc0, PredSpecsAcc), + [], InputSpecDeletePPIds, !PredInfo, !ModuleInfo, + PredSpecsAcc0, PredSpecsAcc), + AfterFrontEnd = SimplifyTasks ^ do_after_front_end, + ( + AfterFrontEnd = not_after_front_end + ; + AfterFrontEnd = after_front_end, + list.foldl(delete_specified_proc, InputSpecDeletePPIds, !ModuleInfo) + ), PredSpecs = diag_spec_accumulator_to_list(PredSpecsAcc), !:Specs = PredSpecs ++ !.Specs, module_info_get_globals(!.ModuleInfo, Globals), @@ -1502,6 +1510,16 @@ simplify_pred(ProgressStream, SimplifyTasks0, PredId, maybe_report_stats(ProgressStream, Statistics, !IO) ). +:- pred delete_specified_proc(pred_proc_id::in, + module_info::in, module_info::out) is det. + +delete_specified_proc(proc(PredId, ProcId), !ModuleInfo) :- + module_info_pred_info(!.ModuleInfo, PredId, PredInfo0), + pred_info_get_proc_table(PredInfo0, ProcTable0), + map.delete(ProcId, ProcTable0, ProcTable), + pred_info_set_proc_table(ProcTable, PredInfo0, PredInfo), + module_info_set_pred_info(PredId, PredInfo, !ModuleInfo). + %---------------------------------------------------------------------------% :- pred maybe_generate_style_warnings(io.text_output_stream::in, diff --git a/compiler/options.m b/compiler/options.m index 9b4e4f98e..9809c5fa5 100644 --- a/compiler/options.m +++ b/compiler/options.m @@ -5678,7 +5678,7 @@ optdb(oc_dev_ctrl, compiler_sufficiently_recent, bool(no), "scout-disj-2025-11-15", "subtype-int2-2026-08-09", "input-spec-2026-08-14", - "input-mode-spec-2026-08-31"], [ + "input-mode-spec-2026-09-01"], [ w("Is the compiler sufficiently recent to contain the new feature"), w("or bugfix referred to by each name?")])). % These options are provided for use by implementors who want to compare diff --git a/compiler/simplify_proc.m b/compiler/simplify_proc.m index e0fdce2c1..dab5ab653 100644 --- a/compiler/simplify_proc.m +++ b/compiler/simplify_proc.m @@ -44,6 +44,7 @@ % :- pred simplify_pred_procs(io.text_output_stream::in, simplify_tasks::in, pred_id::in, list(proc_id)::in, + list(pred_proc_id)::in, list(pred_proc_id)::out, pred_info::in, pred_info::out, module_info::in, module_info::out, diag_spec_accumulator::in, diag_spec_accumulator::out) is det. @@ -126,21 +127,22 @@ %---------------------------------------------------------------------------% -simplify_pred_procs(_, _, _, [], !PredInfo, !ModuleInfo, !Specs). -simplify_pred_procs(ProgressStream, SimplifyTasks, PredId, - [ProcId | ProcIds], !PredInfo, !ModuleInfo, !Specs) :- +simplify_pred_procs(_, _, _, [], + !InputSpecDeletePPIds, !PredInfo, !ModuleInfo, !Specs). +simplify_pred_procs(ProgressStream, SimplifyTasks, PredId, [ProcId | ProcIds], + !InputSpecDeletePPIds, !PredInfo, !ModuleInfo, !Specs) :- simplify_pred_proc(ProgressStream, SimplifyTasks, PredId, ProcId, - !PredInfo, !ModuleInfo, !Specs), + !InputSpecDeletePPIds, !PredInfo, !ModuleInfo, !Specs), simplify_pred_procs(ProgressStream, SimplifyTasks, PredId, ProcIds, - !PredInfo, !ModuleInfo, !Specs). + !InputSpecDeletePPIds, !PredInfo, !ModuleInfo, !Specs). :- pred simplify_pred_proc(io.text_output_stream::in, simplify_tasks::in, - pred_id::in, proc_id::in, pred_info::in, pred_info::out, - module_info::in, module_info::out, + pred_id::in, proc_id::in, list(pred_proc_id)::in, list(pred_proc_id)::out, + pred_info::in, pred_info::out, module_info::in, module_info::out, diag_spec_accumulator::in, diag_spec_accumulator::out) is det. simplify_pred_proc(ProgressStream, SimplifyTasks, PredId, ProcId, - !PredInfo, !ModuleInfo, !Specs) :- + !InputSpecDeletePPIds, !PredInfo, !ModuleInfo, !Specs) :- % XXX It is strange that simplify_proc prints progress messages, % but simplify_pred_proc does not. pred_info_get_proc_table(!.PredInfo, ProcTable0), @@ -166,6 +168,17 @@ simplify_pred_proc(ProgressStream, SimplifyTasks, PredId, ProcId, ; HasUserEvent = has_no_user_event ), + proc_info_get_maybe_input_spec(ProcInfo, MaybeInputSpec), + ( + ( MaybeInputSpec = not_involved_in_input_spec + ; MaybeInputSpec = input_spec_original_proc_kept(_) + ; MaybeInputSpec = input_specialized_proc(_) + ) + ; + MaybeInputSpec = input_spec_original_proc_logically_deleted(_), + PPId = proc(PredId, ProcId), + !:InputSpecDeletePPIds = [PPId | !.InputSpecDeletePPIds] + ), map.det_update(ProcId, ProcInfo, ProcTable0, ProcTable), pred_info_set_proc_table(ProcTable, !PredInfo), accumulate_diag_specs_for_proc(ProcSpecs, !Specs). diff --git a/tests/warnings/help_text.err_exp b/tests/warnings/help_text.err_exp index c0bc5e61f..db055fdc4 100644 --- a/tests/warnings/help_text.err_exp +++ b/tests/warnings/help_text.err_exp @@ -3730,7 +3730,7 @@ Options for developers only --scout-disj-2025-11-15 --subtype-int2-2026-08-09 --input-spec-2026-08-14 - --input-mode-spec-2026-08-31 + --input-mode-spec-2026-09-01 Is the compiler sufficiently recent to contain the new feature or bugfix referred to by each name?