[m-rev.] diff: better singleton variable warnings for clause heads

Zoltan Somogyi zs at csse.unimelb.edu.au
Thu Aug 11 16:36:54 AEST 2011


If a clause head has several singleton variables, generate a single warning for
them, instead of separate warnings for different singletons. The reason why
this wasn't happening already is that the relevant code sees clauses in which
terms in clause heads have already been replaced by headvar variables. The
extra verbosity this generated was annoying.

compiler/make_hlds_warn.m:
	Make the change described above.

	Fix the placement of commas in the messages we produce in another
	circumstance.

	Reduce the amount of parameter passing required by grouping
	always-passed-together arguments into a structure.

	Factor out some common code.

	Give some predicates more meaningful names.

	Put the arguments of some predicates in a more natural order.

compiler/add_class.m:
compiler/add_clause.m:
compiler/add_pragma.m:
	Conform to the changes in make_hlds_warn.m.

tests/warnings/singleton_test.{m,exp,exp2,exp3,exp4}:
	Add a test of the new functionality to this test case, and update the
	expected outputs accordingly. (The .exp{2,3,4} files looked like they
	have missed out on some previous updates, and one of them still looks
	as if it isnt't wrapped right.)

tests/warnings/warn_succ_ind.exp:
	Update this file to expect the fixed version of a message.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/extra
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/extra
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/doc
cvs diff: Diffing boehm_gc/libatomic_ops/src
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/armcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops/tests
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/m4
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/add_class.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_class.m,v
retrieving revision 1.37
diff -u -b -r1.37 add_class.m
--- compiler/add_class.m	23 May 2011 05:07:59 -0000	1.37
+++ compiler/add_class.m	9 Aug 2011 14:55:41 -0000
@@ -679,7 +679,7 @@
         SimpleCallId = simple_call_id(PredOrFunc, PredName, Arity),
 
         % Warn about singleton variables.
-        warn_singletons(VarSet, SimpleCallId, !.ModuleInfo, Goal, !Specs),
+        warn_singletons(!.ModuleInfo, SimpleCallId, VarSet, Goal, !Specs),
 
         % Warn about variables with overlapping scopes.
         warn_overlap(Warnings, VarSet, SimpleCallId, !Specs)
Index: compiler/add_clause.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_clause.m,v
retrieving revision 1.67
diff -u -b -r1.67 add_clause.m
--- compiler/add_clause.m	23 May 2011 05:07:59 -0000	1.67
+++ compiler/add_clause.m	9 Aug 2011 14:55:51 -0000
@@ -275,7 +275,7 @@
                 ;
                     % Warn about singleton variables.
                     SimpleCallId = simple_call_id(PredOrFunc, PredName, Arity),
-                    warn_singletons(VarSet, SimpleCallId, !.ModuleInfo, Goal,
+                    warn_singletons(!.ModuleInfo, SimpleCallId, VarSet, Goal,
                         !Specs),
                     % Warn about variables with overlapping scopes.
                     warn_overlap(Warnings, VarSet, SimpleCallId, !Specs)
Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.120
diff -u -b -r1.120 add_pragma.m
--- compiler/add_pragma.m	16 Jun 2011 07:54:24 -0000	1.120
+++ compiler/add_pragma.m	9 Aug 2011 15:48:07 -0000
@@ -2224,9 +2224,9 @@
                 module_info_set_predicate_table(PredTable, !ModuleInfo),
                 pragma_get_var_infos(PVars, ArgInfoBox),
                 assoc_list.keys(ArgInfoBox, ArgInfo),
-                warn_singletons_in_pragma_foreign_proc(PragmaImpl,
-                    PragmaForeignLanguage, ArgInfo, Context, SimpleCallId,
-                    PredId, ProcId, !.ModuleInfo, !Specs)
+                warn_singletons_in_pragma_foreign_proc(!.ModuleInfo,
+                    PragmaImpl, PragmaForeignLanguage, ArgInfo, Context,
+                    SimpleCallId, PredId, ProcId, !Specs)
             ;
                 Pieces = [words("Error: `:- pragma foreign_proc' declaration"),
                     words("for undeclared mode of"),
Index: compiler/make_hlds_warn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_warn.m,v
retrieving revision 1.39
diff -u -b -r1.39 make_hlds_warn.m
--- compiler/make_hlds_warn.m	6 May 2011 05:03:21 -0000	1.39
+++ compiler/make_hlds_warn.m	10 Aug 2011 01:55:09 -0000
@@ -18,7 +18,6 @@
 :- import_module hlds.hlds_goal.
 :- import_module hlds.hlds_module.
 :- import_module hlds.quantification.
-:- import_module libs.globals.
 :- import_module parse_tree.error_util.
 :- import_module parse_tree.prog_data.
 
@@ -37,7 +36,7 @@
     % but occur more than once, or about variables that do not occur in
     % C code strings when they should.
     %
-:- pred warn_singletons(prog_varset::in, simple_call_id::in, module_info::in,
+:- pred warn_singletons(module_info::in, simple_call_id::in, prog_varset::in,
     hlds_goal::in, list(error_spec)::in, list(error_spec)::out) is det.
 
     % warn_singletons_in_pragma_foreign_proc checks to see if each variable
@@ -48,10 +47,11 @@
     % to do this check, or you may need to add a transformation to map
     % Mercury variable names into identifiers for that foreign language).
     %
-:- pred warn_singletons_in_pragma_foreign_proc(pragma_foreign_code_impl::in,
-    foreign_language::in, list(maybe(pair(string, mer_mode)))::in,
-    prog_context::in, simple_call_id::in, pred_id::in, proc_id::in,
-    module_info::in, list(error_spec)::in, list(error_spec)::out) is det.
+:- pred warn_singletons_in_pragma_foreign_proc(module_info::in,
+    pragma_foreign_code_impl::in, foreign_language::in,
+    list(maybe(pair(string, mer_mode)))::in, prog_context::in,
+    simple_call_id::in, pred_id::in, proc_id::in,
+    list(error_spec)::in, list(error_spec)::out) is det.
 
     % This predicate performs the following checks on promise ex declarations
     % (see notes/promise_ex.html).
@@ -72,6 +72,7 @@
 
 :- import_module check_hlds.mode_util.
 :- import_module hlds.goal_util.
+:- import_module libs.globals.
 :- import_module libs.options.
 :- import_module parse_tree.mercury_to_mercury.
 :- import_module parse_tree.prog_out.
@@ -114,34 +115,104 @@
 
 %-----------------------------------------------------------------------------%
 
-warn_singletons(VarSet, PredCallId, ModuleInfo, Body, !Specs) :-
-    set.init(QuantVars),
-    warn_singletons_in_goal(Body, QuantVars, VarSet, PredCallId,
-        ModuleInfo, !Specs).
+warn_singletons(ModuleInfo, PredCallId, VarSet, Body, !Specs) :-
+    % We handle warnings about variables in the clause head specially.
+    % This is because the compiler transforms clause heads such as
+    %
+    % p(X, Y, Z) :- ...
+    %
+    % into
+    %
+    % p(HV1, HV2, HV3) :- HV1 = X, HV2 = Y, HV3 = Z, ...
+    %
+    % If more than one of the head variables is a singleton, programmers
+    % would expect a single warning naming them all, since to programmers,
+    % everything in the clause head is part of the same scope, but for the
+    % compiler, the singleton nature of e.g. Y is detected in its own scope,
+    % to wit, the HV2 = Y unification.
+    %
+    % Even though we discover the singleton nature of e.g. Y in that
+    % unification, we don't generate a warning for that scope. Instead,
+    % we gather all the singleton variables in the head, and generate a single
+    % message for them all here.
+    %
+    % We also do the same thing for variables whose names indicate they should
+    % be singletons, but aren't.
+
+    Info0 = warn_info(ModuleInfo, PredCallId, VarSet,
+        [], set.init, set.init, context_init),
+    QuantVars = set.init,
+    warn_singletons_in_goal(Body, QuantVars, Info0, Info),
+    Info = warn_info(_ModuleInfo, _PredCallId, _VarSet,
+        NewSpecs, SingletonHeadVarsSet, MultiHeadVarsSet, HeadContext),
+    !:Specs = NewSpecs ++ !.Specs,
+    set.to_sorted_list(SingletonHeadVarsSet, SingletonHeadVars),
+    set.to_sorted_list(MultiHeadVarsSet, MultiHeadVars),
+    (
+        SingletonHeadVars = []
+    ;
+        SingletonHeadVars = [_ | _],
+        generate_variable_warning(sm_single, HeadContext, PredCallId, VarSet,
+            SingletonHeadVars, SingleSpec),
+        !:Specs = [SingleSpec | !.Specs]
+    ),
+    (
+        MultiHeadVars = []
+    ;
+        MultiHeadVars = [_ | _],
+        generate_variable_warning(sm_multi, HeadContext, PredCallId, VarSet,
+            MultiHeadVars, MultiSpec),
+        !:Specs = [MultiSpec | !.Specs]
+    ).
+
+:- type warn_info
+    --->    warn_info(
+                % The current module.
+                wi_module_info          :: module_info,
+
+                % The id and the varset of the procedure whose body
+                % we are checking.
+                wi_pred_call_id         :: simple_call_id,
+                wi_varset               :: prog_varset,
+
+                % The warnings we have generated while checking.
+                wi_specs                :: list(error_spec),
+
+                % The set of variables that occur singleton in the clause head.
+                wi_singleton_headvars   :: set(prog_var),
+
+                % The set of variables that occur more than once in the clause
+                % head, even though their names say they SHOULD be singletons.
+                wi_multi_headvars       :: set(prog_var),
+
+                % The context of the clause head. Should be set to a meaningful
+                % value if either wi_singleton_headvars or wi_multi_headvars
+                % is not empty.
+                %
+                % It is possible for the clause head to occupy more than one
+                % line, and thus for different parts of it to have different
+                % contexts. Since we want to generate only a single error_spec,
+                % we arbitrarily pick the context of one of those variables.
+                wi_head_context         :: prog_context
+            ).
 
 :- pred warn_singletons_in_goal(hlds_goal::in, set(prog_var)::in,
-    prog_varset::in, simple_call_id::in, module_info::in,
-    list(error_spec)::in, list(error_spec)::out) is det.
+    warn_info::in, warn_info::out) is det.
 
-warn_singletons_in_goal(Goal, QuantVars, VarSet, PredCallId, ModuleInfo,
-        !Specs) :-
+warn_singletons_in_goal(Goal, QuantVars, !Info) :-
     Goal = hlds_goal(GoalExpr, GoalInfo),
     (
         GoalExpr = conj(_ConjType, Goals),
-        warn_singletons_in_goal_list(Goals, QuantVars, VarSet, PredCallId,
-            ModuleInfo, !Specs)
+        warn_singletons_in_goal_list(Goals, QuantVars, !Info)
     ;
         GoalExpr = disj(Goals),
-        warn_singletons_in_goal_list(Goals, QuantVars, VarSet, PredCallId,
-            ModuleInfo, !Specs)
+        warn_singletons_in_goal_list(Goals, QuantVars, !Info)
     ;
         GoalExpr = switch(_Var, _CanFail, Cases),
-        warn_singletons_in_cases(Cases, QuantVars, VarSet, PredCallId,
-            ModuleInfo, !Specs)
+        warn_singletons_in_cases(Cases, QuantVars, !Info)
     ;
         GoalExpr = negation(SubGoal),
-        warn_singletons_in_goal(SubGoal, QuantVars, VarSet, PredCallId,
-            ModuleInfo, !Specs)
+        warn_singletons_in_goal(SubGoal, QuantVars, !Info)
     ;
         GoalExpr = scope(Reason, SubGoal),
         % Warn if any quantified variables occur only in the quantifier.
@@ -153,15 +224,14 @@
                 Vars = [_ | _],
                 SubGoalVars = free_goal_vars(SubGoal),
                 set.init(EmptySet),
-                warn_singletons_goal_vars(Vars, GoalInfo, EmptySet, SubGoalVars,
-                    VarSet, PredCallId, !Specs),
+                warn_singletons_goal_vars(Vars, GoalInfo, EmptySet,
+                    SubGoalVars, !Info),
                 set.insert_list(Vars, QuantVars, SubQuantVars)
             ;
                 Vars = [],
                 SubQuantVars = QuantVars
             ),
-            warn_singletons_in_goal(SubGoal, SubQuantVars, VarSet, PredCallId,
-                ModuleInfo, !Specs)
+            warn_singletons_in_goal(SubGoal, SubQuantVars, !Info)
         ;
             ( Reason = promise_purity(_)
             ; Reason = require_detism(_)
@@ -170,17 +240,16 @@
             ; Reason = barrier(_)
             ; Reason = trace_goal(_, _, _, _, _)
             ),
-            warn_singletons_in_goal(SubGoal, QuantVars, VarSet, PredCallId,
-                ModuleInfo, !Specs)
+            warn_singletons_in_goal(SubGoal, QuantVars, !Info)
         ;
             Reason = from_ground_term(TermVar, _Kind),
             % There can be no singleton variables inside the scopes by
-            % construction. The only variable involved in the scope
-            % that can possibly be singleton is the one representing the entire
+            % construction. The only variable involved in the scope that
+            % can possibly be singleton is the one representing the entire
             % ground term.
             NonLocals = goal_info_get_nonlocals(GoalInfo),
             warn_singletons_goal_vars([TermVar], GoalInfo, NonLocals,
-                QuantVars, VarSet, PredCallId, !Specs)
+                QuantVars, !Info)
         )
     ;
         GoalExpr = if_then_else(Vars, Cond, Then, Else),
@@ -194,41 +263,37 @@
             set.union(CondVars, ThenVars, CondThenVars),
             set.init(EmptySet),
             warn_singletons_goal_vars(Vars, GoalInfo, EmptySet, CondThenVars,
-                VarSet, PredCallId, !Specs)
+                !Info)
         ;
             Vars = []
         ),
         set.insert_list(Vars, QuantVars, CondThenQuantVars),
-        warn_singletons_in_goal(Cond, CondThenQuantVars, VarSet, PredCallId,
-            ModuleInfo, !Specs),
-        warn_singletons_in_goal(Then, CondThenQuantVars, VarSet, PredCallId,
-            ModuleInfo, !Specs),
-        warn_singletons_in_goal(Else, QuantVars, VarSet, PredCallId,
-            ModuleInfo, !Specs)
+        warn_singletons_in_goal(Cond, CondThenQuantVars, !Info),
+        warn_singletons_in_goal(Then, CondThenQuantVars, !Info),
+        warn_singletons_in_goal(Else, QuantVars, !Info)
     ;
         GoalExpr = plain_call(_, _, Args, _, _, _),
         NonLocals = goal_info_get_nonlocals(GoalInfo),
-        warn_singletons_goal_vars(Args, GoalInfo, NonLocals, QuantVars, VarSet,
-            PredCallId, !Specs)
+        warn_singletons_goal_vars(Args, GoalInfo, NonLocals, QuantVars, !Info)
     ;
         GoalExpr = generic_call(GenericCall, Args0, _, _),
         goal_util.generic_call_vars(GenericCall, Args1),
-        list.append(Args0, Args1, Args),
+        Args = Args0 ++ Args1,
         NonLocals = goal_info_get_nonlocals(GoalInfo),
-        warn_singletons_goal_vars(Args, GoalInfo, NonLocals, QuantVars, VarSet,
-            PredCallId, !Specs)
+        warn_singletons_goal_vars(Args, GoalInfo, NonLocals, QuantVars, !Info)
     ;
         GoalExpr = unify(Var, RHS, _, _, _),
-        warn_singletons_in_unify(Var, RHS, GoalInfo, QuantVars, VarSet,
-            PredCallId, ModuleInfo, !Specs)
+        warn_singletons_in_unify(Var, RHS, GoalInfo, QuantVars, !Info)
     ;
         GoalExpr = call_foreign_proc(Attrs, PredId, ProcId, Args, _, _,
             PragmaImpl),
         Context = goal_info_get_context(GoalInfo),
         Lang = get_foreign_language(Attrs),
         NamesModes = list.map(foreign_arg_maybe_name_mode, Args),
-        warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang,
-            NamesModes, Context, PredCallId, PredId, ProcId, ModuleInfo, !Specs)
+        warn_singletons_in_pragma_foreign_proc(!.Info ^ wi_module_info,
+            PragmaImpl, Lang, NamesModes, Context, !.Info ^ wi_pred_call_id,
+            PredId, ProcId, [], PragmaSpecs),
+        list.foldl(add_warn_spec, PragmaSpecs, !Info)
     ;
         GoalExpr = shorthand(ShortHand),
         (
@@ -238,79 +303,66 @@
                 _MaybeOutputVars, MainGoal, OrElseGoals, _OrElseInners),
             Inner = atomic_interface_vars(InnerDI, InnerUO),
             set.insert_list([InnerDI, InnerUO], QuantVars, InsideQuantVars),
-            warn_singletons_in_goal(MainGoal, InsideQuantVars, VarSet,
-                PredCallId, ModuleInfo, !Specs),
-            warn_singletons_in_goal_list(OrElseGoals, InsideQuantVars, VarSet,
-                PredCallId, ModuleInfo, !Specs)
+            warn_singletons_in_goal(MainGoal, InsideQuantVars, !Info),
+            warn_singletons_in_goal_list(OrElseGoals, InsideQuantVars, !Info)
         ;
             ShortHand = try_goal(_, _, SubGoal),
-            warn_singletons_in_goal(SubGoal, QuantVars, VarSet,
-                PredCallId, ModuleInfo, !Specs)
+            warn_singletons_in_goal(SubGoal, QuantVars, !Info)
         ;
             ShortHand = bi_implication(GoalA, GoalB),
-            warn_singletons_in_goal_list([GoalA, GoalB], QuantVars, VarSet,
-                PredCallId, ModuleInfo, !Specs)
+            warn_singletons_in_goal_list([GoalA, GoalB], QuantVars, !Info)
         )
     ).
 
 :- pred warn_singletons_in_goal_list(list(hlds_goal)::in, set(prog_var)::in,
-    prog_varset::in, simple_call_id::in, module_info::in,
-    list(error_spec)::in, list(error_spec)::out) is det.
+    warn_info::in, warn_info::out) is det.
 
-warn_singletons_in_goal_list([], _, _, _, _, !Specs).
-warn_singletons_in_goal_list([Goal | Goals], QuantVars, VarSet, CallPredId,
-        ModuleInfo, !Specs) :-
-    warn_singletons_in_goal(Goal, QuantVars, VarSet, CallPredId,
-        ModuleInfo, !Specs),
-    warn_singletons_in_goal_list(Goals, QuantVars, VarSet, CallPredId,
-        ModuleInfo, !Specs).
+warn_singletons_in_goal_list([], _, !Info).
+warn_singletons_in_goal_list([Goal | Goals], QuantVars, !Info) :-
+    warn_singletons_in_goal(Goal, QuantVars, !Info),
+    warn_singletons_in_goal_list(Goals, QuantVars, !Info).
 
 :- pred warn_singletons_in_cases(list(case)::in, set(prog_var)::in,
-    prog_varset::in, simple_call_id::in, module_info::in,
-    list(error_spec)::in, list(error_spec)::out) is det.
+    warn_info::in, warn_info::out) is det.
 
-warn_singletons_in_cases([], _, _, _, _, !IO).
-warn_singletons_in_cases([Case | Cases], QuantVars, VarSet, CallPredId,
-        ModuleInfo, !Specs) :-
+warn_singletons_in_cases([], _, !Info).
+warn_singletons_in_cases([Case | Cases], QuantVars, !Info) :-
     Case = case(_MainConsId, _OtherConsIds, Goal),
-    warn_singletons_in_goal(Goal, QuantVars, VarSet, CallPredId,
-        ModuleInfo, !Specs),
-    warn_singletons_in_cases(Cases, QuantVars, VarSet, CallPredId,
-        ModuleInfo, !Specs).
-
-:- pred warn_singletons_in_unify(prog_var::in, unify_rhs::in,
-    hlds_goal_info::in, set(prog_var)::in, prog_varset::in,
-    simple_call_id::in, module_info::in,
-    list(error_spec)::in, list(error_spec)::out) is det.
+    warn_singletons_in_goal(Goal, QuantVars, !Info),
+    warn_singletons_in_cases(Cases, QuantVars, !Info).
+
+:- pred warn_singletons_in_unify(prog_var::in,
+    unify_rhs::in, hlds_goal_info::in, set(prog_var)::in,
+    warn_info::in, warn_info::out) is det.
 
-warn_singletons_in_unify(X, rhs_var(Y), GoalInfo, QuantVars, VarSet,
-        CallPredId, _, !Specs) :-
+warn_singletons_in_unify(X, RHS, GoalInfo, QuantVars, !Info) :-
+    (
+        RHS = rhs_var(Y),
     NonLocals = goal_info_get_nonlocals(GoalInfo),
     warn_singletons_goal_vars([X, Y], GoalInfo, NonLocals, QuantVars,
-        VarSet, CallPredId, !Specs).
-warn_singletons_in_unify(X, rhs_functor(_ConsId, _, Vars), GoalInfo,
-        QuantVars, VarSet, CallPredId, _, !Specs) :-
+            !Info)
+    ;
+        RHS = rhs_functor(_ConsId, _, Ys),
     NonLocals = goal_info_get_nonlocals(GoalInfo),
-    warn_singletons_goal_vars([X | Vars], GoalInfo, NonLocals, QuantVars,
-        VarSet, CallPredId, !Specs).
-warn_singletons_in_unify(X, rhs_lambda_goal(_Purity, _Groundness, _PredOrFunc,
+        warn_singletons_goal_vars([X | Ys], GoalInfo, NonLocals, QuantVars,
+            !Info)
+    ;
+        RHS = rhs_lambda_goal(_Purity, _Groundness, _PredOrFunc,
         _Eval, _NonLocals, LambdaVars, _Modes, _Det, LambdaGoal),
-        GoalInfo, QuantVars, VarSet, CallPredId, ModuleInfo, !Specs) :-
     % Warn if any lambda-quantified variables occur only in the quantifier.
     LambdaGoal = hlds_goal(_, LambdaGoalInfo),
     LambdaNonLocals = goal_info_get_nonlocals(LambdaGoalInfo),
-    warn_singletons_goal_vars(LambdaVars, GoalInfo, LambdaNonLocals, QuantVars,
-        VarSet, CallPredId, !Specs),
+        warn_singletons_goal_vars(LambdaVars, GoalInfo, LambdaNonLocals,
+            QuantVars, !Info),
 
     % Warn if X (the variable we're unifying the lambda expression with)
     % is singleton.
     NonLocals = goal_info_get_nonlocals(GoalInfo),
-    warn_singletons_goal_vars([X], GoalInfo, NonLocals, QuantVars,
-        VarSet, CallPredId, !Specs),
+        warn_singletons_goal_vars([X], GoalInfo, NonLocals, QuantVars, !Info),
 
     % Warn if the lambda-goal contains singletons.
-    warn_singletons_in_goal(LambdaGoal, QuantVars, VarSet, CallPredId,
-        ModuleInfo, !Specs).
+        warn_singletons_in_goal(LambdaGoal, QuantVars, !Info)
+    ).
 
 %-----------------------------------------------------------------------------%
 
@@ -321,51 +373,41 @@
     % or if any of the underscore variables in Vars do occur in NonLocals.
     % Omit the warning if GoalInfo says we should.
     %
-:- pred warn_singletons_goal_vars(list(prog_var)::in, hlds_goal_info::in,
-    set(prog_var)::in, set(prog_var)::in, prog_varset::in, simple_call_id::in,
-    list(error_spec)::in, list(error_spec)::out) is det.
+:- pred warn_singletons_goal_vars(list(prog_var)::in,
+    hlds_goal_info::in, set(prog_var)::in, set(prog_var)::in,
+    warn_info::in, warn_info::out) is det.
 
-warn_singletons_goal_vars(GoalVars, GoalInfo, NonLocals, QuantVars, VarSet,
-        PredOrFuncCallId, !Specs) :-
+warn_singletons_goal_vars(GoalVars, GoalInfo, NonLocals, QuantVars, !Info) :-
     % Find all the variables in the goal that don't occur outside the goal
     % (i.e. are singleton), have a variable name that doesn't start with "_"
     % or "DCG_", and don't have the same name as any variable in QuantVars
     % (i.e. weren't explicitly quantified).
 
+    VarSet = !.Info ^ wi_varset,
+    CallId = !.Info ^ wi_pred_call_id,
+    Context = goal_info_get_context(GoalInfo),
+
     list.filter(is_singleton_var(NonLocals, QuantVars, VarSet), GoalVars,
         SingleVars),
 
     % If there were any such variables, issue a warning.
     (
-        (
-            SingleVars = []
-        ;
-            goal_info_has_feature(GoalInfo, feature_dont_warn_singleton)
+        ( SingleVars = []
+        ; goal_info_has_feature(GoalInfo, feature_dont_warn_singleton)
         )
     ->
         true
     ;
-        SinglesPreamble = [words("In clause for"),
-            simple_call(PredOrFuncCallId), suffix(":"), nl],
-        SingleVarStrs0 = list.map(mercury_var_to_string(VarSet, no),
-            SingleVars),
-        list.sort_and_remove_dups(SingleVarStrs0, SingleVarStrs),
-        SingleVarsPiece = quote(string.join_list(", ", SingleVarStrs)),
-        ( SingleVarStrs = [_] ->
-            SinglesPieces = [words("warning: variable"), SingleVarsPiece,
-                words("occurs only once in this scope."), nl]
-        ;
-            SinglesPieces = [words("warning: variables"), SingleVarsPiece,
-                words("occur only once in this scope."), nl]
-        ),
-        SinglesMsg = simple_msg(goal_info_get_context(GoalInfo),
-            [option_is_set(warn_singleton_vars, yes,
-                [always(SinglesPreamble ++ SinglesPieces)])]),
-        SingleSeverity = severity_conditional(warn_singleton_vars, yes,
-            severity_warning, no),
-        SinglesSpec = error_spec(SingleSeverity, phase_parse_tree_to_hlds,
-            [SinglesMsg]),
-        !:Specs = [SinglesSpec | !.Specs]
+        ( goal_info_has_feature(GoalInfo, feature_from_head) ->
+            SingleHeadVars0 = !.Info ^ wi_singleton_headvars,
+            set.insert_list(SingleVars, SingleHeadVars0, SingleHeadVars),
+            !Info ^ wi_singleton_headvars := SingleHeadVars,
+            !Info ^ wi_head_context := goal_info_get_context(GoalInfo)
+        ;
+            generate_variable_warning(sm_single, Context, CallId, VarSet,
+                SingleVars, SingleSpec),
+            add_warn_spec(SingleSpec, !Info)
+        )
     ),
 
     % Find all the variables in the goal that do occur outside the goal
@@ -377,33 +419,63 @@
         MultiVars = []
     ;
         MultiVars = [_ | _],
-        MultiPreamble = [words("In clause for"),
-            simple_call(PredOrFuncCallId), suffix(":"), nl],
-        MultiVarStrs0 = list.map(mercury_var_to_string(VarSet, no),
-            MultiVars),
-        list.sort_and_remove_dups(MultiVarStrs0, MultiVarStrs),
-        MultiVarsPiece = quote(string.join_list(", ", MultiVarStrs)),
-        ( MultiVarStrs = [_] ->
-            MultiPieces = [words("warning: variable"), MultiVarsPiece,
-                words("occurs more than once in this scope."), nl]
+        ( goal_info_has_feature(GoalInfo, feature_from_head) ->
+            MultiHeadVars0 = !.Info ^ wi_multi_headvars,
+            set.insert_list(MultiVars, MultiHeadVars0, MultiHeadVars),
+            !Info ^ wi_multi_headvars := MultiHeadVars,
+            !Info ^ wi_head_context := goal_info_get_context(GoalInfo)
+        ;
+            generate_variable_warning(sm_multi, Context, CallId, VarSet,
+                MultiVars, MultiSpec),
+            add_warn_spec(MultiSpec, !Info)
+        )
+    ).
+
+:- type single_or_multi
+    --->    sm_single
+    ;       sm_multi.
+
+:- pred generate_variable_warning(single_or_multi::in, prog_context::in,
+    simple_call_id::in, prog_varset::in, list(prog_var)::in, error_spec::out)
+    is det.
+
+generate_variable_warning(SingleMulti, Context, CallId, VarSet, Vars, Spec) :-
+    (
+        SingleMulti = sm_single,
+        Count = "only once"
         ;
-            MultiPieces = [words("warning: variables"), MultiVarsPiece,
-                words("occur more than once in this scope."), nl]
+        SingleMulti = sm_multi,
+        Count = "more than once"
         ),
-        MultiMsg = simple_msg(goal_info_get_context(GoalInfo),
+    Preamble = [words("In clause for"), simple_call(CallId), suffix(":"), nl],
+    VarStrs0 = list.map(mercury_var_to_string(VarSet, no), Vars),
+    list.sort_and_remove_dups(VarStrs0, VarStrs),
+    VarsPiece = quote(string.join_list(", ", VarStrs)),
+    ( VarStrs = [_] ->
+        Pieces = [words("warning: variable"), VarsPiece,
+            words("occurs"), words(Count), words("in this scope."), nl]
+    ;
+        Pieces = [words("warning: variables"), VarsPiece,
+            words("occur"), words(Count), words("in this scope."), nl]
+    ),
+    Msg = simple_msg(Context,
             [option_is_set(warn_singleton_vars, yes,
-                [always(MultiPreamble ++ MultiPieces)])]),
-        MultiSeverity = severity_conditional(warn_singleton_vars, yes,
+            [always(Preamble ++ Pieces)])]),
+    Severity = severity_conditional(warn_singleton_vars, yes,
             severity_warning, no),
-        MultiSpec = error_spec(MultiSeverity, phase_parse_tree_to_hlds,
-            [MultiMsg]),
-        !:Specs = [MultiSpec | !.Specs]
-    ).
+    Spec = error_spec(Severity, phase_parse_tree_to_hlds, [Msg]).
+
+:- pred add_warn_spec(error_spec::in, warn_info::in, warn_info::out) is det.
+
+add_warn_spec(Spec, !Info) :-
+    Specs0 = !.Info ^ wi_specs,
+    Specs = [Spec | Specs0],
+    !Info ^ wi_specs := Specs.
 
 %-----------------------------------------------------------------------------%
 
-warn_singletons_in_pragma_foreign_proc(PragmaImpl, Lang, Args, Context,
-        PredOrFuncCallId, PredId, ProcId, ModuleInfo, !Specs) :-
+warn_singletons_in_pragma_foreign_proc(ModuleInfo, PragmaImpl, Lang,
+        Args, Context, SimpleCallId, PredId, ProcId, !Specs) :-
     LangStr = foreign_language_string(Lang),
     PragmaImpl = fc_impl_ordinary(C_Code, _),
     c_code_to_name_list(C_Code, C_CodeList),
@@ -412,21 +484,19 @@
         UnmentionedVars = []
     ;
         UnmentionedVars = [_ | _],
-        Pieces1 = [words("In the"), words(LangStr), words("code for"),
-            simple_call(PredOrFuncCallId), suffix(":"), nl] ++
+        Pieces = [words("In the"), words(LangStr), words("code for"),
+            simple_call(SimpleCallId), suffix(":"), nl] ++
             variable_warning_start(UnmentionedVars) ++
-            [words("not occur in the"), words(LangStr), words("code."),
-            nl],
-        Msg1 = simple_msg(Context,
-            [option_is_set(warn_singleton_vars, yes, [always(Pieces1)])]),
-        Severity1 = severity_conditional(warn_singleton_vars, yes,
+            [words("not occur in the"), words(LangStr), words("code."), nl],
+        Msg = simple_msg(Context,
+            [option_is_set(warn_singleton_vars, yes, [always(Pieces)])]),
+        Severity = severity_conditional(warn_singleton_vars, yes,
             severity_warning, no),
-        Spec1 = error_spec(Severity1, phase_parse_tree_to_hlds,
-            [Msg1]),
-        !:Specs = [Spec1 | !.Specs]
+        Spec = error_spec(Severity, phase_parse_tree_to_hlds, [Msg]),
+        !:Specs = [Spec | !.Specs]
     ),
-    pragma_foreign_proc_body_checks(Lang, Context, PredOrFuncCallId,
-        PredId, ProcId, ModuleInfo, C_CodeList, !Specs).
+    pragma_foreign_proc_body_checks(ModuleInfo, Lang, Context, SimpleCallId,
+        PredId, ProcId, C_CodeList, !Specs).
 
 :- pred var_is_unmentioned(list(string)::in, maybe(pair(string, mer_mode))::in,
     string::out) is semidet.
@@ -542,13 +612,12 @@
     varset.search_name(VarSet, Var, Name),
     string.prefix(Name, "_").
 
-:- pred pragma_foreign_proc_body_checks(foreign_language::in,
+:- pred pragma_foreign_proc_body_checks(module_info::in, foreign_language::in,
     prog_context::in, simple_call_id::in, pred_id::in, proc_id::in,
-    module_info::in, list(string)::in,
-    list(error_spec)::in, list(error_spec)::out) is det.
+    list(string)::in, list(error_spec)::in, list(error_spec)::out) is det.
 
-pragma_foreign_proc_body_checks(Lang, Context, PredOrFuncCallId, PredId, ProcId,
-        ModuleInfo, BodyPieces, !Specs) :-
+pragma_foreign_proc_body_checks(ModuleInfo, Lang, Context, SimpleCallId,
+        PredId, ProcId, BodyPieces, !Specs) :-
     module_info_pred_info(ModuleInfo, PredId, PredInfo),
     pred_info_get_import_status(PredInfo, ImportStatus),
     IsImported = status_is_imported(ImportStatus),
@@ -556,19 +625,19 @@
         IsImported = yes
     ;
         IsImported = no,
-        check_fp_body_for_success_indicator(Lang, Context, PredOrFuncCallId,
-            PredId, ProcId, ModuleInfo, BodyPieces, !Specs),
-        check_fp_body_for_return(Lang, Context, PredOrFuncCallId, BodyPieces,
+        check_fp_body_for_success_indicator(ModuleInfo, Lang, Context,
+            SimpleCallId, PredId, ProcId, BodyPieces, !Specs),
+        check_fp_body_for_return(Lang, Context, SimpleCallId, BodyPieces,
             !Specs)
     ).
 
-:- pred check_fp_body_for_success_indicator(foreign_language::in,
-    prog_context::in, simple_call_id::in, pred_id::in, proc_id::in,
-    module_info::in, list(string)::in,
+:- pred check_fp_body_for_success_indicator(module_info::in,
+    foreign_language::in, prog_context::in, simple_call_id::in,
+    pred_id::in, proc_id::in, list(string)::in,
     list(error_spec)::in, list(error_spec)::out) is det.
 
-check_fp_body_for_success_indicator(Lang, Context, CallId, PredId, ProcId,
-        ModuleInfo, BodyPieces, !Specs) :-
+check_fp_body_for_success_indicator(ModuleInfo, Lang, Context, SimpleCallId,
+        PredId, ProcId, BodyPieces, !Specs) :-
     module_info_proc_info(ModuleInfo, PredId, ProcId, ProcInfo),
     proc_info_get_declared_determinism(ProcInfo, MaybeDeclDetism),
     (
@@ -580,19 +649,18 @@
             ; Lang = lang_java
             ),
             SuccIndStr = "SUCCESS_INDICATOR",
-            ( if    list.member(SuccIndStr, BodyPieces)
-              then
-                    LangStr = foreign_language_string(Lang),
                     (
                         ( Detism = detism_det
                         ; Detism = detism_cc_multi
                         ; Detism = detism_erroneous
                         ),
+                ( list.member(SuccIndStr, BodyPieces) ->
+                    LangStr = foreign_language_string(Lang),
                         Pieces = [
                             words("warning: the "), fixed(LangStr),
-                            words("code for"), simple_call(CallId),
-                            words("may set"), quote(SuccIndStr),
-                            words(", but it cannot fail.")
+                        words("code for"), simple_call(SimpleCallId),
+                        words("may set"), quote(SuccIndStr), suffix(","),
+                        words("but it cannot fail.")
                         ],
                         Msg = simple_msg(Context,
                             [option_is_set(warn_suspicious_foreign_procs, yes,
@@ -604,25 +672,22 @@
                             [Msg]),
                         !:Specs = [Spec | !.Specs]
                     ;
-                        ( Detism = detism_semi
-                        ; Detism = detism_multi
-                        ; Detism = detism_non
-                        ; Detism = detism_cc_non
-                        ; Detism = detism_failure
-                        )
+                    true
                     )
-              else
-                    (
+            ;
                         ( Detism = detism_semi
                         ; Detism = detism_cc_non
                         ),
+                ( list.member(SuccIndStr, BodyPieces) ->
+                    true
+                ;
                         LangStr = foreign_language_string(Lang),
                         Pieces = [
                             words("warning: the "), fixed(LangStr),
-                            words("code for"), simple_call(CallId),
+                        words("code for"), simple_call(SimpleCallId),
                             words("does not appear to set"),
-                            quote(SuccIndStr),
-                            words(", but it can fail.")
+                        quote(SuccIndStr), suffix(","),
+                        words("but it can fail.")
                         ],
                         Msg = simple_msg(Context,
                             [option_is_set(warn_suspicious_foreign_procs, yes,
@@ -633,14 +698,11 @@
                         Spec = error_spec(Severity, phase_parse_tree_to_hlds,
                             [Msg]),
                         !:Specs = [Spec | !.Specs]
+                )
                     ;
-                        ( Detism = detism_det
-                        ; Detism = detism_cc_multi
-                        ; Detism = detism_failure
+                ( Detism = detism_multi
                         ; Detism = detism_non
-                        ; Detism = detism_multi
-                        ; Detism = detism_erroneous
-                        )
+                ; Detism = detism_failure
                     )
             )
         ;
@@ -653,24 +715,23 @@
     % Check to see if a foreign_proc body contains a return statement
     % (or whatever the foreign language equivalent is).
     %
-:- pred check_fp_body_for_return(foreign_language::in,
-    prog_context::in, simple_call_id::in, list(string)::in, 
+:- pred check_fp_body_for_return(foreign_language::in, prog_context::in,
+    simple_call_id::in, list(string)::in,
     list(error_spec)::in, list(error_spec)::out) is det.
 
-check_fp_body_for_return(Lang, Context, Id, BodyPieces, !Specs) :-
+check_fp_body_for_return(Lang, Context, SimpleCallId, BodyPieces, !Specs) :-
     (
         ( Lang = lang_c
         ; Lang = lang_csharp
         ; Lang = lang_java
         ),
-        ( if    list.member("return", BodyPieces)
-          then
+        ( list.member("return", BodyPieces) ->
                 LangStr = foreign_language_string(Lang),
                 Pieces = [
-                    words("warning: the "), fixed(LangStr), words("code for"),
-                    simple_call(Id),
+                words("warning: the "), fixed(LangStr),
+                words("code for"), simple_call(SimpleCallId),
                     words("may contain a"), quote("return"),
-                    words("statement.")
+                words("statement."), nl
                 ],
                 Msg = simple_msg(Context,
                     [option_is_set(warn_suspicious_foreign_procs, yes,
@@ -680,21 +741,21 @@
                     warn_suspicious_foreign_procs, yes, severity_warning, no),
                 Spec = error_spec(Severity, phase_parse_tree_to_hlds, [Msg]),
                 !:Specs = [Spec | !.Specs]
-          else
+        ;
                 true
         )
     ;
         Lang = lang_il,
-        ( if    ( list.member("ret", BodyPieces)
+        (
+            ( list.member("ret", BodyPieces)
                 ; list.member("jmp", BodyPieces)
                 )
-          then
+        ->
                 Pieces = [
-                    words("warning: the IL code for"),
-                    simple_call(Id),
+                words("warning: the IL code for"), simple_call(SimpleCallId),
                     words("may contain a"), quote("ret"),
                     words("or"), quote("jmp"),
-                    words("instruction.")
+                words("instruction."), nl
                 ],
                 Msg = simple_msg(Context,
                     [option_is_set(warn_suspicious_foreign_procs, yes,
@@ -704,7 +765,7 @@
                     warn_suspicious_foreign_procs, yes, severity_warning, no),
                 Spec = error_spec(Severity, phase_parse_tree_to_hlds, [Msg]),
                 !:Specs = [Spec | !.Specs]
-          else
+        ;
                 true
         )
     ;
@@ -739,7 +800,7 @@
     ; GoalExpr = disj_expr(_, _) ->
         flatten_to_disj_list(GoalExpr - Context, DisjList),
         list.map(flatten_to_conj_list, DisjList, DisjConjList),
-        check_disjunction(PromiseType, DisjConjList, !Specs)
+        check_promise_ex_disjunction(PromiseType, DisjConjList, !Specs)
     ; GoalExpr = all_expr(_UnivVars, Goal) ->
         promise_ex_error(PromiseType, Context,
             "universal quantification should come before " ++
@@ -780,33 +841,34 @@
 
     % Taking a list of arms of the disjunction, check each arm individually.
     %
-:- pred check_disjunction(promise_type::in, list(goals)::in,
+:- pred check_promise_ex_disjunction(promise_type::in, list(goals)::in,
     list(error_spec)::in, list(error_spec)::out) is det.
 
-check_disjunction(PromiseType, DisjConjList, !Specs) :-
+check_promise_ex_disjunction(PromiseType, DisjConjList, !Specs) :-
     (
         DisjConjList = []
     ;
         DisjConjList = [ConjList | Rest],
-        check_disj_arm(PromiseType, ConjList, no, !Specs),
-        check_disjunction(PromiseType, Rest, !Specs)
+        check_promise_ex_disj_arm(PromiseType, ConjList, no, !Specs),
+        check_promise_ex_disjunction(PromiseType, Rest, !Specs)
     ).
 
     % Only one goal in an arm is allowed to be a call, the rest must be
     % unifications.
     %
-:- pred check_disj_arm(promise_type::in, goals::in, bool::in,
+:- pred check_promise_ex_disj_arm(promise_type::in, goals::in, bool::in,
     list(error_spec)::in, list(error_spec)::out) is det.
 
-check_disj_arm(PromiseType, Goals, CallUsed, !Specs) :-
+check_promise_ex_disj_arm(PromiseType, Goals, CallUsed, !Specs) :-
     (
         Goals = []
     ;
         Goals = [GoalExpr - Context | Rest],
         ( GoalExpr = unify_expr(_, _, _) ->
-            check_disj_arm(PromiseType, Rest, CallUsed, !Specs)
+            check_promise_ex_disj_arm(PromiseType, Rest, CallUsed, !Specs)
         ; GoalExpr = some_expr(_, Goal) ->
-            check_disj_arm(PromiseType, [Goal | Rest], CallUsed, !Specs)
+            check_promise_ex_disj_arm(PromiseType, [Goal | Rest], CallUsed,
+                !Specs)
         ; GoalExpr = call_expr(_, _, _) ->
             (
                 CallUsed = no
@@ -815,11 +877,11 @@
                 promise_ex_error(PromiseType, Context,
                     "disjunct contains more than one call", !Specs)
             ),
-            check_disj_arm(PromiseType, Rest, yes, !Specs)
+            check_promise_ex_disj_arm(PromiseType, Rest, yes, !Specs)
         ;
             promise_ex_error(PromiseType, Context,
                 "disjunct is not a call or unification", !Specs),
-            check_disj_arm(PromiseType, Rest, CallUsed, !Specs)
+            check_promise_ex_disj_arm(PromiseType, Rest, CallUsed, !Specs)
         )
     ).
 
cvs diff: Diffing compiler/notes
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_cairo
cvs diff: Diffing extras/graphics/mercury_cairo/samples
cvs diff: Diffing extras/graphics/mercury_cairo/samples/data
cvs diff: Diffing extras/graphics/mercury_cairo/tutorial
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/monte
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/appengine
cvs diff: Diffing samples/appengine/war
cvs diff: Diffing samples/appengine/war/WEB-INF
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/concurrency
cvs diff: Diffing samples/concurrency/dining_philosophers
cvs diff: Diffing samples/concurrency/midimon
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/java_interface
cvs diff: Diffing samples/java_interface/java_calls_mercury
cvs diff: Diffing samples/java_interface/mercury_calls_java
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/stm
cvs diff: Diffing tests/stm/orig
cvs diff: Diffing tests/stm/orig/stm-compiler
cvs diff: Diffing tests/stm/orig/stm-compiler/test1
cvs diff: Diffing tests/stm/orig/stm-compiler/test10
cvs diff: Diffing tests/stm/orig/stm-compiler/test2
cvs diff: Diffing tests/stm/orig/stm-compiler/test3
cvs diff: Diffing tests/stm/orig/stm-compiler/test4
cvs diff: Diffing tests/stm/orig/stm-compiler/test5
cvs diff: Diffing tests/stm/orig/stm-compiler/test6
cvs diff: Diffing tests/stm/orig/stm-compiler/test7
cvs diff: Diffing tests/stm/orig/stm-compiler/test8
cvs diff: Diffing tests/stm/orig/stm-compiler/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/stmqueue
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test10
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test11
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test9
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
Index: tests/warnings/singleton_test.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/singleton_test.exp,v
retrieving revision 1.16
diff -u -b -r1.16 singleton_test.exp
--- tests/warnings/singleton_test.exp	10 Sep 2010 05:15:05 -0000	1.16
+++ tests/warnings/singleton_test.exp	11 Aug 2011 03:50:01 -0000
@@ -5,17 +5,23 @@
 singleton_test.m:008:     L1: V_1
 singleton_test.m:008:   The unbound type variables will be implicitly bound to
 singleton_test.m:008:   the builtin type `void'.
-singleton_test.m:022: In clause for predicate `singleton_test.my_append'/3:
-singleton_test.m:022:   warning: variable `L2' occurs only once in this scope.
-singleton_test.m:026: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:026:   warning: variables `L1, L2' occur only once in this
-singleton_test.m:026:   scope.
-singleton_test.m:027: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:027:   warning: variable `T' occurs only once in this scope.
-singleton_test.m:029: In the C code for predicate `singleton_test.my_c_pred'/3:
-singleton_test.m:029:   warning: variable `Y' does not occur in the C code.
-singleton_test.m:046: In the C code for function `singleton_test.my_c_func'/2:
-singleton_test.m:046:   warning: variable `X' does not occur in the C code.
-singleton_test.m:065: In the C code for predicate
-singleton_test.m:065:   `singleton_test.c_hello_world'/3:
-singleton_test.m:065:   warning: variable `Msg' does not occur in the C code.
+singleton_test.m:026: In clause for predicate `singleton_test.my_append'/3:
+singleton_test.m:026:   warning: variable `L2' occurs only once in this scope.
+singleton_test.m:030: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:030:   warning: variables `L1, L2' occur only once in this
+singleton_test.m:030:   scope.
+singleton_test.m:031: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:031:   warning: variable `T' occurs only once in this scope.
+singleton_test.m:033: In the C code for predicate `singleton_test.my_c_pred'/3:
+singleton_test.m:033:   warning: variable `Y' does not occur in the C code.
+singleton_test.m:050: In the C code for function `singleton_test.my_c_func'/2:
+singleton_test.m:050:   warning: variable `X' does not occur in the C code.
+singleton_test.m:069: In the C code for predicate
+singleton_test.m:069:   `singleton_test.c_hello_world'/3:
+singleton_test.m:069:   warning: variable `Msg' does not occur in the C code.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variable `_D' occurs more than once in this
+singleton_test.m:090:   scope.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variables `A, B' occur only once in this
+singleton_test.m:090:   scope.
Index: tests/warnings/singleton_test.exp2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/singleton_test.exp2,v
retrieving revision 1.3
diff -u -b -r1.3 singleton_test.exp2
--- tests/warnings/singleton_test.exp2	23 Aug 2007 04:08:40 -0000	1.3
+++ tests/warnings/singleton_test.exp2	11 Aug 2011 03:50:25 -0000
@@ -1,17 +1,3 @@
-singleton_test.m:022: In clause for predicate `singleton_test.my_append'/3:
-singleton_test.m:022:   warning: variable `L2' occurs only once in this scope.
-singleton_test.m:026: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:026:   warning: variables `L1, L2' occur only once in this
-singleton_test.m:026:   scope.
-singleton_test.m:027: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:027:   warning: variable `T' occurs only once in this scope.
-singleton_test.m:032: In the C# code for predicate `singleton_test.my_c_pred'/3:
-singleton_test.m:032:   warning: variable `Y' does not occur in the C# code.
-singleton_test.m:048: In the C# code for function `singleton_test.my_c_func'/2:
-singleton_test.m:048:   warning: variable `X' does not occur in the C# code.
-singleton_test.m:068: In the C# code for predicate
-singleton_test.m:068:   `singleton_test.c_hello_world/3':
-singleton_test.m:068:   warning: variable `Msg' does not occur in the C# code.
 singleton_test.m:008: In function `my_append_func'/2:
 singleton_test.m:008:   warning: unresolved polymorphism.
 singleton_test.m:008:   The variables with unbound types were:
@@ -19,3 +5,23 @@
 singleton_test.m:008:     L1: V_1
 singleton_test.m:008:   The unbound type variables will be implicitly bound to
 singleton_test.m:008:   the builtin type `void'.
+singleton_test.m:026: In clause for predicate `singleton_test.my_append'/3:
+singleton_test.m:026:   warning: variable `L2' occurs only once in this scope.
+singleton_test.m:030: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:030:   warning: variables `L1, L2' occur only once in this
+singleton_test.m:030:   scope.
+singleton_test.m:031: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:031:   warning: variable `T' occurs only once in this scope.
+singleton_test.m:036: In the C# code for predicate `singleton_test.my_c_pred'/3:
+singleton_test.m:036:   warning: variable `Y' does not occur in the C# code.
+singleton_test.m:052: In the C# code for function `singleton_test.my_c_func'/2:
+singleton_test.m:052:   warning: variable `X' does not occur in the C# code.
+singleton_test.m:072: In the C# code for predicate
+singleton_test.m:072:   `singleton_test.c_hello_world/3':
+singleton_test.m:072:   warning: variable `Msg' does not occur in the C# code.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variable `_D' occurs more than once in this
+singleton_test.m:090:   scope.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variables `A, B' occur only once in this
+singleton_test.m:090:   scope.
Index: tests/warnings/singleton_test.exp3
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/singleton_test.exp3,v
retrieving revision 1.2
diff -u -b -r1.2 singleton_test.exp3
--- tests/warnings/singleton_test.exp3	23 Aug 2007 04:08:40 -0000	1.2
+++ tests/warnings/singleton_test.exp3	11 Aug 2011 03:51:04 -0000
@@ -1,16 +1,3 @@
-singleton_test.m:022: In clause for predicate `singleton_test.my_append'/3:
-singleton_test.m:022:   warning: variable `L2' occurs only once in this scope.
-singleton_test.m:026: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:026:   warning: variables `L1, L2' occur only once in this
-singleton_test.m:026:   scope.
-singleton_test.m:027: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:027:   warning: variable `T' occurs only once in this scope.
-singleton_test.m:036: In the Java code for predicate `singleton_test.my_c_pred'/3:
-singleton_test.m:036:   warning: variable `Y' does not occur in the Java code.
-singleton_test.m:052: In the Java code for function `singleton_test.my_c_func'/2:
-singleton_test.m:052:   warning: variable `X' does not occur in the Java code.
-singleton_test.m:073: In the Java code for predicate `singleton_test.c_hello_world'/3:
-singleton_test.m:073:   warning: variable `Msg' does not occur in the Java code.
 singleton_test.m:008: In function `singleton_test.my_append_func'/2:
 singleton_test.m:008:   warning: unresolved polymorphism.
 singleton_test.m:008:   The variables with unbound types were:
@@ -18,3 +5,22 @@
 singleton_test.m:008:     L1: V_1
 singleton_test.m:008:   The unbound type variables will be implicitly bound to
 singleton_test.m:008:   the builtin type `void'.
+singleton_test.m:026: In clause for predicate `singleton_test.my_append'/3:
+singleton_test.m:026:   warning: variable `L2' occurs only once in this scope.
+singleton_test.m:030: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:030:   warning: variables `L1, L2' occur only once in this
+singleton_test.m:030:   scope.
+singleton_test.m:031: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:031:   warning: variable `T' occurs only once in this scope.
+singleton_test.m:040: In the Java code for predicate `singleton_test.my_c_pred'/3:
+singleton_test.m:040:   warning: variable `Y' does not occur in the Java code.
+singleton_test.m:056: In the Java code for function `singleton_test.my_c_func'/2:
+singleton_test.m:056:   warning: variable `X' does not occur in the Java code.
+singleton_test.m:077: In the Java code for predicate `singleton_test.c_hello_world'/3:
+singleton_test.m:077:   warning: variable `Msg' does not occur in the Java code.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variable `_D' occurs more than once in this
+singleton_test.m:090:   scope.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variables `A, B' occur only once in this
+singleton_test.m:090:   scope.
Index: tests/warnings/singleton_test.exp4
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/singleton_test.exp4,v
retrieving revision 1.1
diff -u -b -r1.1 singleton_test.exp4
--- tests/warnings/singleton_test.exp4	23 Aug 2007 04:08:40 -0000	1.1
+++ tests/warnings/singleton_test.exp4	11 Aug 2011 03:51:40 -0000
@@ -1,22 +1,3 @@
-singleton_test.m:022: In clause for predicate `singleton_test.my_append'/3:
-singleton_test.m:022:   warning: variable `L2' occurs only once in this scope.
-singleton_test.m:026: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:026:   warning: variables `L1, L2' occur only once in this
-singleton_test.m:026:   scope.
-singleton_test.m:027: In clause for function `singleton_test.my_append_func'/2:
-singleton_test.m:027:   warning: variable `T' occurs only once in this scope.
-singleton_test.m:040: In the Erlang code for predicate
-singleton_test.m:040:   `singleton_test.my_c_pred'/3:
-singleton_test.m:040:   warning: variable `Y' does not occur in the Erlang
-singleton_test.m:040:   code.
-singleton_test.m:056: In the Erlang code for function
-singleton_test.m:056:   `singleton_test.my_c_func'/2:
-singleton_test.m:056:   warning: variable `X' does not occur in the Erlang
-singleton_test.m:056:   code.
-singleton_test.m:078: In the Erlang code for predicate
-singleton_test.m:078:   `singleton_test.c_hello_world'/3:
-singleton_test.m:078:   warning: variable `Msg' does not occur in the Erlang
-singleton_test.m:078:   code.
 singleton_test.m:008: In function `my_append_func'/2:
 singleton_test.m:008:   warning: unresolved polymorphism.
 singleton_test.m:008:   The variables with unbound types were:
@@ -24,3 +5,28 @@
 singleton_test.m:008:     L1: V_1
 singleton_test.m:008:   The unbound type variables will be implicitly bound to
 singleton_test.m:008:   the builtin type `void'.
+singleton_test.m:026: In clause for predicate `singleton_test.my_append'/3:
+singleton_test.m:026:   warning: variable `L2' occurs only once in this scope.
+singleton_test.m:030: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:030:   warning: variables `L1, L2' occur only once in this
+singleton_test.m:030:   scope.
+singleton_test.m:031: In clause for function `singleton_test.my_append_func'/2:
+singleton_test.m:031:   warning: variable `T' occurs only once in this scope.
+singleton_test.m:044: In the Erlang code for predicate
+singleton_test.m:044:   `singleton_test.my_c_pred'/3:
+singleton_test.m:044:   warning: variable `Y' does not occur in the Erlang
+singleton_test.m:044:   code.
+singleton_test.m:060: In the Erlang code for function
+singleton_test.m:060:   `singleton_test.my_c_func'/2:
+singleton_test.m:060:   warning: variable `X' does not occur in the Erlang
+singleton_test.m:060:   code.
+singleton_test.m:082: In the Erlang code for predicate
+singleton_test.m:082:   `singleton_test.c_hello_world'/3:
+singleton_test.m:082:   warning: variable `Msg' does not occur in the Erlang
+singleton_test.m:082:   code.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variable `_D' occurs more than once in this
+singleton_test.m:090:   scope.
+singleton_test.m:090: In clause for predicate `singleton_test.test_head'/6:
+singleton_test.m:090:   warning: variables `A, B' occur only once in this
+singleton_test.m:090:   scope.
Index: tests/warnings/singleton_test.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/singleton_test.m,v
retrieving revision 1.9
diff -u -b -r1.9 singleton_test.m
--- tests/warnings/singleton_test.m	10 Sep 2010 05:15:05 -0000	1.9
+++ tests/warnings/singleton_test.m	11 Aug 2011 03:46:11 -0000
@@ -15,6 +15,10 @@
 :- mode my_c_pred(in, in, out) is det.
 
 :- pred c_hello_world(string::in, io__state::di, io__state::uo) is det.
+
+:- pred test_head(int::in, int::in, int::in, int::in, int::out, int::out)
+	is det.
+
 :- implementation.
 :- import_module int.
 
@@ -82,3 +86,5 @@
 	io:format(""Hello, world""),
 	IO = IO0
 ").
+
+test_head(A, B, C, _D, C, _D).
Index: tests/warnings/warn_succ_ind.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/warn_succ_ind.exp,v
retrieving revision 1.1
diff -u -b -r1.1 warn_succ_ind.exp
--- tests/warnings/warn_succ_ind.exp	8 Sep 2009 08:14:42 -0000	1.1
+++ tests/warnings/warn_succ_ind.exp	9 Aug 2011 17:01:01 -0000
@@ -1,10 +1,10 @@
 warn_succ_ind.m:016: warning: the C code for predicate `warn_succ_ind.foo'/2
-warn_succ_ind.m:016:   may set `SUCCESS_INDICATOR' , but it cannot fail.
+warn_succ_ind.m:016:   may set `SUCCESS_INDICATOR', but it cannot fail.
 warn_succ_ind.m:048: warning: the C code for predicate `warn_succ_ind.foo2'/2
-warn_succ_ind.m:048:   may set `SUCCESS_INDICATOR' , but it cannot fail.
+warn_succ_ind.m:048:   may set `SUCCESS_INDICATOR', but it cannot fail.
 warn_succ_ind.m:080: warning: the C code for predicate `warn_succ_ind.bar'/2
-warn_succ_ind.m:080:   does not appear to set `SUCCESS_INDICATOR' , but it can
+warn_succ_ind.m:080:   does not appear to set `SUCCESS_INDICATOR', but it can
 warn_succ_ind.m:080:   fail.
 warn_succ_ind.m:108: warning: the C code for predicate `warn_succ_ind.bar2'/2
-warn_succ_ind.m:108:   does not appear to set `SUCCESS_INDICATOR' , but it can
+warn_succ_ind.m:108:   does not appear to set `SUCCESS_INDICATOR', but it can
 warn_succ_ind.m:108:   fail.
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list