[m-rev.] for review: disable_warnings scope
Paul Bone
paul at bone.id.au
Thu Jan 19 11:54:08 AEDT 2017
On Thu, Jan 19, 2017 at 10:47:19AM +1100, Zoltan Somogyi wrote:
>
> The attached diff implements option (a), as the above email and the reply
> to it agreed. It fixes the failure of the require_tailrec_1 test case in MLDS grades.
>
> Once this is installed, we can publically document the ability to disable
> warnings about non-tail recursive calls.
>
> For review by anyone.
>
> diff --git a/compiler/ml_code_gen.m b/compiler/ml_code_gen.m
> index ea2dc5d..3f6a469 100644
> --- a/compiler/ml_code_gen.m
> +++ b/compiler/ml_code_gen.m
> @@ -666,19 +667,47 @@ ml_gen_goal_expr(GoalExpr, CodeModel, Context, GoalInfo, Decls, Statements,
> ml_gen_negation(SubGoal, CodeModel, Context, Decls, Statements, !Info)
> ;
> GoalExpr = scope(Reason, SubGoal),
> - ( if
> - Reason = from_ground_term(TermVar, from_ground_term_construct)
> - then
> + (
> + Reason = from_ground_term(TermVar, from_ground_term_construct),
> ml_gen_ground_term(TermVar, SubGoal, Statements, !Info),
> Decls = []
> - else
> + ;
> + ( Reason = from_ground_term(_, from_ground_term_deconstruct)
> + ; Reason = from_ground_term(_, from_ground_term_other)
> + ; Reason = promise_purity(_)
> + ; Reason = require_detism(_)
> + ; Reason = require_complete_switch(_)
> + ; Reason = require_switch_arms_detism(_, _)
> + ; Reason = trace_goal(_, _, _, _, _)
> + ; Reason = loop_control(_, _, _) % XXX NYI
Loop control isn't implemented for the MLDS. We can throw an exception here
and if it's implmeneted in the future we'll know to come back and fix it.
> + ),
> + ml_gen_goal(CodeModel, SubGoal, Decls, Statements, !Info)
> + ;
> + ( Reason = exist_quant(_)
> + ; Reason = commit(_)
> + ; Reason = barrier(_)
> + ; Reason = promise_solutions(_, _)
> + ),
> ml_gen_commit(SubGoal, CodeModel, Context, Decls, Statements,
> !Info)
> + ;
> + Reason = disable_warnings(HeadWarning, TailWarnings),
> + ml_gen_info_get_disabled_warnings(!.Info, Warnings0),
> + set.insert_list([HeadWarning | TailWarnings], Warnings0, Warnings),
> + ml_gen_info_set_disabled_warnings(Warnings, !Info),
> + ml_gen_commit(SubGoal, CodeModel, Context, Decls, Statements,
> + !Info),
What's the purpose of ml_gen_commit here? Why not ml_gen_goal?
> + ml_gen_info_set_disabled_warnings(Warnings0, !Info)
> + ;
> + Reason = from_ground_term(_, from_ground_term_initial),
> + % These should have been replaced by one of the other
> + % from_ground_term_* scopes.
> + unexpected($module, "unexpected from_ground_term_initial")
> )
> ;
> GoalExpr = shorthand(_),
> - % these should have been expanded out by now
> - unexpected($module, $pred, "unexpected shorthand")
> + % These should have been expanded out by now.
> + unexpected($module, "unexpected shorthand")
> ).
>
> %-----------------------------------------------------------------------------%
The rest is good. Thanks.
--
Paul Bone
http://paul.bone.id.au
More information about the reviews
mailing list