Make non-tail-recursion reports work with trailing. compiler/mark_tail_calls.m: Do not consider trailing grades to be inherently unable to support tail recursion. Instead, change the main goal traversal to be able to single out the one situation in which trailing can turn a normally tail-recursive call into a non-tail-recursive one. This requires keeping track of the reasons why calls before a certain program point cannot be tail recursive, which is the same as keeping track of what operations happen after that program point. Crucially, these operations can consist of not just Mercury code (which is user visible) but also of code added by the Mercury compiler (which is not user visible). Most of the complexity of the code that tracks this occurs when handling branched control structures. To make their handling simpler, always keep track of the set of operations after each program point *explicitly*; the operand of a union operation cannot be a set that the representation has designed out. NEWS.md: Announce the require_tail_recursion and disable_non_tail_recursion_reports pragmas. compiler/hlds_markers.m: Add a new goal feature that mark_tail_calls.m can use to avoid getting duplicate warnings about non-tail-recursive recursive calls from both - mark_tail_calls.m's procedure body traversal, and - the MLDS code generator. Initially, we got them only from the code generator, then from both, the duplicates not being a problem because write_error_spec.m filters out any duplicates. They would be a problem now because the code generator has less info. This can generate messages that are less informative, and thus also not filterable *exact* duplicates. compiler/ml_gen_info.m: Give the MLDS code generator access to this new feature. compiler/ml_call_gen.m: compiler/ml_closure_gen.m: compiler/ml_proc_gen.m: compiler/saved_vars.m: Conform to the changes above. doc/mercury_reference_manual.texi: Do not imply that trailing *always* destroys tail recursion. compiler/add_trail_ops.m: Minor code clarifications. tests/warnings/trail_non_tailcall.m: tests/warnings/trail_non_tailcall.err_exp: tests/warnings/trail_non_tailcall.err_exp2: A version of Julien's code that motivated this change, added as a new regression test. tests/warnings/Mmakefile: Enable the new test case. tests/invalid/Mmakefile: Sort a list of test case names.