[m-rev.] for review: warnings in duplicated code
Zoltan Somogyi
zs at cs.mu.OZ.AU
Thu May 25 17:05:43 AEST 2006
For unifications of the form X = f, we usually emit warnings if we know
from previous unifications that X cannot be bound to f. There was already
one exception to this: if some of the procedure's arguments had initial insts
such as in(g), because in such cases the failure of the unification could be
caused by this initial mode, and the exact same unification could succeed
in another mode in which the initial inst of that variable is in(f).
This diff adds another exception: when the unification is in code that was
duplicated by switch detection. Consider this code:
% switch on X
(
X = e,
...
;
( X = f
; X = g
; X = h
),
...
( X = f ->
...
;
...
)
)
The idea is that cases of f, g and h are handled mostly the same way, but that
f needs a bit of special handling. This used to give a warning, because the
switch detection creates three copies of the if-then-else: one each inside
the switch arms for f, g and h. In the arm for f, the condition cannot fail,
and in the arms for g and h, the condition cannot succeed, yet giving warnings
about the condition not being able to fail or succeed would be misleading.
compiler/hlds_goal.m:
Add a goal feature to denote that the goal is duplicated by switch
detection.
compiler/saved_vars.m:
Conform to the new feature.
compiler/switch_detection.m:
Attach this feature to goals as they are being duplicated.
compiler/mode_info.m:
Add a field to the mode_info that says whether we are inside such
goals.
compiler/modes.m:
compiler/unique_modes.m:
Set this field appropriately.
compiler/modecheck_unify.m:
When finding a unification of the form X = f where the inst of X
says that it cannot be bound to X, only generate a warning if we are
not inside a duplicated goal.
compiler/simplify.m:
Add a field to the simplify_ that says whether we are inside
a duplicated goal, keep it up to date, and don't generate warnings
about too-simple if-then-elses if the field say they could be due to
the code duplication.
tests/hard_coded/switch_detect.m:
Extend this existing test case to test the new behavior.
tests/hard_coded/Mercury.options:
Force the compilation of switch_detect.m to fail if there are any
warnings.
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/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.156
diff -u -b -r1.156 hlds_goal.m
--- compiler/hlds_goal.m 10 May 2006 10:56:50 -0000 1.156
+++ compiler/hlds_goal.m 24 May 2006 06:16:39 -0000
@@ -1006,6 +1006,10 @@
% mark the unifications it creates, and get
% the singleton warning code to respect it.
+ ; duplicated_for_switch
+ % This goal was created by switch detection by
+ % duplicating the source code written by the user.
+
; mode_check_clauses_goal
% This goal is the main disjunction of a predicate
% with the mode_check_clauses pragma. No compiler
Index: compiler/mode_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_info.m,v
retrieving revision 1.87
diff -u -b -r1.87 mode_info.m
--- compiler/mode_info.m 29 Mar 2006 08:07:07 -0000 1.87
+++ compiler/mode_info.m 24 May 2006 07:37:31 -0000
@@ -143,6 +143,7 @@
may_change_called_proc::out) is det.
:- pred mode_info_get_initial_instmap(mode_info::in, instmap::out) is det.
:- pred mode_info_get_in_from_ground_term(mode_info::in, bool::out) is det.
+:- pred mode_info_get_in_dupl_for_switch(mode_info::in, bool::out) is det.
%-----------------------------------------------------------------------------%
@@ -202,6 +203,8 @@
mode_info::in, mode_info::out) is det.
:- pred mode_info_set_in_from_ground_term(bool::in,
mode_info::in, mode_info::out) is det.
+:- pred mode_info_set_in_dupl_for_switch(bool::in,
+ mode_info::in, mode_info::out) is det.
%-----------------------------------------------------------------------------%
@@ -336,7 +339,11 @@
% Set to `yes' if we are in a from_ground_term scope.
% This information allows us to optimize some aspects of
% mode analysis.
- in_from_ground_term :: bool
+ in_from_ground_term :: bool,
+
+ % Set to `yes' if we are inside a goal with a
+ % duplicate_for_switch feature.
+ in_dupl_for_switch :: bool
).
:- type mode_info
@@ -463,7 +470,7 @@
ModeSubInfo = mode_sub_info(ProcId, VarSet, Unreachable, Changed,
CheckingExtraGoals, InstMapping0, WarningList, NeedToRequantify,
- InNegatedContext, no),
+ InNegatedContext, no, no),
ModeInfo = mode_info(ModuleInfo, PredId, VarTypes, Debug,
Context, ModeContext, InstMapping0, LockedVars, DelayInfo,
@@ -500,6 +507,8 @@
mode_info_get_initial_instmap(MI, MI ^ mode_sub_info ^ initial_instmap).
mode_info_get_in_from_ground_term(MI,
MI ^ mode_sub_info ^ in_from_ground_term).
+mode_info_get_in_dupl_for_switch(MI,
+ MI ^ mode_sub_info ^ in_dupl_for_switch).
mode_info_set_module_info(ModuleInfo, MI, MI ^ module_info := ModuleInfo).
mode_info_set_predid(PredId, MI, MI ^ predid := PredId).
@@ -530,6 +539,8 @@
MI ^ may_change_called_proc := MayChange).
mode_info_set_in_from_ground_term(FGI, MI,
MI ^ mode_sub_info ^ in_from_ground_term := FGI).
+mode_info_set_in_dupl_for_switch(INFS, MI,
+ MI ^ mode_sub_info ^ in_dupl_for_switch := INFS).
%-----------------------------------------------------------------------------%
Index: compiler/modecheck_unify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_unify.m,v
retrieving revision 1.102
diff -u -b -r1.102 modecheck_unify.m
--- compiler/modecheck_unify.m 29 Mar 2006 08:07:09 -0000 1.102
+++ compiler/modecheck_unify.m 24 May 2006 07:45:55 -0000
@@ -692,6 +692,8 @@
(
WarnCannotSucceed = yes,
InitMayHaveSubtype = init_instmap_may_have_subtype(!.ModeInfo),
+ mode_info_get_in_dupl_for_switch(!.ModeInfo, InDupForSwitch),
+ (
(
InitMayHaveSubtype = yes
% Suppress the warning, since the unification may succeed
@@ -699,7 +701,13 @@
% or of another head variable that is unified with it,
% is not so constrained.
;
- InitMayHaveSubtype = no,
+ InDupForSwitch = yes
+ % Suppress the warning, since the unification may succeed
+ % in another copy of this duplicated switch arm.
+ )
+ ->
+ true
+ ;
Warning = cannot_succeed_var_functor(X, InstOfX, ConsId),
mode_info_warning(Warning, !ModeInfo)
)
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.332
diff -u -b -r1.332 modes.m
--- compiler/modes.m 20 Apr 2006 05:36:57 -0000 1.332
+++ compiler/modes.m 24 May 2006 07:39:46 -0000
@@ -279,6 +279,19 @@
% The following predicates are used by modecheck_unify.m.
+ % Modecheck a goal by abstractly interpreting it, as explained
+ % at the top of this file.
+ %
+ % Input-output:
+ % InstMap Stored in ModeInfo
+ % DelayInfo Stored in ModeInfo
+ % Goal Passed as an argument pair
+ % Input only:
+ % ModuleInfo Stored in ModeInfo (constant)
+ % Context Stored in ModeInfo (changing as we go along the clause)
+ % Output only:
+ % Error Messages Output directly to stdout.
+ %
:- pred modecheck_goal(hlds_goal::in, hlds_goal::out,
mode_info::in, mode_info::out, io::di, io::uo) is det.
@@ -1222,26 +1235,10 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-% Modecheck a goal by abstractly interpreting it, as explained
-% at the top of this file.
-
-% Note: any changes here may need to be duplicated in unique_modes.m.
-
-% Input-output: InstMap - Stored in the ModeInfo, which is passed as an
-% argument pair
-% DelayInfo - Stored in the ModeInfo
-% Goal - Passed as an argument pair
-% Input only: Symbol tables (constant)
-% - Stored in the ModuleInfo which is in the ModeInfo
-% Context Info (changing as we go along the clause)
-% - Stored in the ModeInfo
-% Output only: Error Message(s)
-% - Output directly to stdout.
-
modecheck_goal(Goal0 - GoalInfo0, Goal - GoalInfo, !ModeInfo, !IO) :-
- %
- % store the current context in the mode_info
- %
+ % Note: any changes here may need to be duplicated in unique_modes.m.
+
+ % Store the current context in the mode_info.
goal_info_get_context(GoalInfo0, Context),
term.context_init(EmptyContext),
( Context = EmptyContext ->
@@ -1249,14 +1246,19 @@
;
mode_info_set_context(Context, !ModeInfo)
),
- %
- % modecheck the goal, and then store the changes in
- % instantiation of the vars in the delta_instmap
- % in the goal's goal_info.
- %
+ mode_info_get_in_dupl_for_switch(!.ModeInfo, InDuplForSwitch),
+ ( goal_info_has_feature(GoalInfo0, duplicated_for_switch) ->
+ mode_info_set_in_dupl_for_switch(yes, !ModeInfo)
+ ;
+ true
+ ),
+
+ % Modecheck the goal, and then store the changes in instantiation
+ % of the vars in the delta_instmap in the goal's goal_info.
mode_info_get_instmap(!.ModeInfo, InstMap0),
modecheck_goal_expr(Goal0, GoalInfo0, Goal, !ModeInfo, !IO),
- compute_goal_instmap_delta(InstMap0, Goal, GoalInfo0, GoalInfo, !ModeInfo).
+ compute_goal_instmap_delta(InstMap0, Goal, GoalInfo0, GoalInfo, !ModeInfo),
+ mode_info_set_in_dupl_for_switch(InDuplForSwitch, !ModeInfo).
compute_goal_instmap_delta(InstMap0, Goal, !GoalInfo, !ModeInfo) :-
( Goal = conj(plain_conj, []) ->
Index: compiler/saved_vars.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.64
diff -u -b -r1.64 saved_vars.m
--- compiler/saved_vars.m 28 Apr 2006 04:13:23 -0000 1.64
+++ compiler/saved_vars.m 24 May 2006 06:32:45 -0000
@@ -228,6 +228,7 @@
ok_to_duplicate(keep_constant_binding) = no.
ok_to_duplicate(save_deep_excp_vars) = no.
ok_to_duplicate(dont_warn_singleton) = yes.
+ok_to_duplicate(duplicated_for_switch) = yes.
ok_to_duplicate(mode_check_clauses_goal) = yes.
ok_to_duplicate(will_not_modify_trail) = yes.
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.176
diff -u -b -r1.176 simplify.m
--- compiler/simplify.m 3 May 2006 06:46:16 -0000 1.176
+++ compiler/simplify.m 24 May 2006 08:13:47 -0000
@@ -515,6 +515,13 @@
simplify_goal(Goal0, GoalExpr - GoalInfo, !Info, !IO) :-
Goal0 = _ - GoalInfo0,
+ simplify_info_get_inside_duplicated_for_switch(!.Info,
+ InsideDuplForSwitch),
+ ( goal_info_has_feature(GoalInfo0, duplicated_for_switch) ->
+ simplify_info_set_inside_duplicated_for_switch(yes, !Info)
+ ;
+ true
+ ),
goal_info_get_determinism(GoalInfo0, Detism),
simplify_info_get_det_info(!.Info, DetInfo),
simplify_info_get_module_info(!.Info, ModuleInfo0),
@@ -659,6 +666,7 @@
Goal3 = GoalExpr3 - GoalInfo3,
simplify_goal_2(GoalExpr3, GoalExpr, GoalInfo3, GoalInfo4, !Info, !IO),
simplify_info_maybe_clear_structs(after, GoalExpr - GoalInfo4, !Info),
+ simplify_info_set_inside_duplicated_for_switch(InsideDuplForSwitch, !Info),
enforce_invariant(GoalInfo4, GoalInfo, !Info).
% Ensure that the mode information and the determinism
@@ -1082,10 +1090,21 @@
list.append(CondList, ThenList, List),
simplify_goal(conj(plain_conj, List) - GoalInfo0, Goal - GoalInfo,
!Info, !IO),
+ simplify_info_get_inside_duplicated_for_switch(!.Info,
+ InsideDuplForSwitch),
+ (
+ InsideDuplForSwitch = yes
+ % Do not generate the warning, since it is quite likely to be
+ % spurious: though the condition cannot fail in this arm of the
+ % switch, it likely can fail in other arms that derive from
+ % the exact same piece of source code.
+ ;
+ InsideDuplForSwitch = no,
goal_info_get_context(GoalInfo0, Context),
Msg = ite_cond_cannot_fail,
ContextMsg = context_det_msg(Context, Msg),
- simplify_info_add_det_msg(ContextMsg, !Info),
+ simplify_info_add_det_msg(ContextMsg, !Info)
+ ),
simplify_info_set_requantify(!Info),
simplify_info_set_rerun_det(!Info)
; CondSolns0 = at_most_zero ->
@@ -1126,10 +1145,21 @@
List = [Cond | ElseList],
simplify_goal(conj(plain_conj, List) - GoalInfo0, Goal - GoalInfo,
!Info, !IO),
+ simplify_info_get_inside_duplicated_for_switch(!.Info,
+ InsideDuplForSwitch),
+ (
+ InsideDuplForSwitch = yes
+ % Do not generate the warning, since it is quite likely to be
+ % spurious: though the condition cannot succeed in this arm of the
+ % switch, it likely can succeed in other arms that derive from
+ % the exact same piece of source code.
+ ;
+ InsideDuplForSwitch = no,
goal_info_get_context(GoalInfo0, Context),
Msg = ite_cond_cannot_succeed,
ContextMsg = context_det_msg(Context, Msg),
- simplify_info_add_det_msg(ContextMsg, !Info),
+ simplify_info_add_det_msg(ContextMsg, !Info)
+ ),
simplify_info_set_requantify(!Info),
simplify_info_set_rerun_det(!Info)
; Else0 = disj([]) - _ ->
@@ -1436,7 +1466,7 @@
PredId \= ThisPredId,
% Don't warn about calls from predicates that also have a
- % `pramga obsolete' declaration. Doing so just results in
+ % `pragma obsolete' declaration. Doing so just results in
% spurious warnings.
module_info_pred_info(ModuleInfo, ThisPredId, ThisPredInfo),
pred_info_get_markers(ThisPredInfo, ThisPredMarkers),
@@ -2414,9 +2444,12 @@
rtti_varmaps :: rtti_varmaps,
% Information about type_infos and
% typeclass_infos.
- format_calls :: bool
+ format_calls :: bool,
% Do we have any calls to
% string.format and io.format?
+ inside_dupl_for_switch :: bool
+ % Are we currently inside a goal
+ % that was duplicated for a switch?
).
simplify_info_init(DetInfo, Simplifications, InstMap, ProcInfo, Info) :-
@@ -2426,7 +2459,7 @@
set.init(Msgs),
Info = simplify_info(DetInfo, Msgs, Simplifications,
common_info_init, InstMap, VarSet, InstVarSet,
- no, no, no, 0, 0, RttiVarMaps, no).
+ no, no, no, 0, 0, RttiVarMaps, no, no).
% Reinitialise the simplify_info before reprocessing a goal.
%
@@ -2492,6 +2525,8 @@
:- implementation.
:- pred simplify_info_get_format_calls(simplify_info::in, bool::out) is det.
+:- pred simplify_info_get_inside_duplicated_for_switch(simplify_info::in,
+ bool::out) is det.
simplify_info_get_det_info(Info, Info ^ det_info).
simplify_info_get_det_msgs(Info, Info ^ msgs).
@@ -2510,6 +2545,8 @@
simplify_info_get_cost_delta(Info, Info ^ cost_delta).
simplify_info_get_rtti_varmaps(Info, Info ^ rtti_varmaps).
simplify_info_get_format_calls(Info, Info ^ format_calls).
+simplify_info_get_inside_duplicated_for_switch(Info,
+ Info ^ inside_dupl_for_switch).
simplify_info_get_module_info(Info, ModuleInfo) :-
simplify_info_get_det_info(Info, DetInfo),
@@ -2537,6 +2574,8 @@
simplify_info::in, simplify_info::out) is det.
:- pred simplify_info_set_format_calls(bool::in,
simplify_info::in, simplify_info::out) is det.
+:- pred simplify_info_set_inside_duplicated_for_switch(bool::in,
+ simplify_info::in, simplify_info::out) is det.
:- pred simplify_info_add_det_msg(context_det_msg::in,
simplify_info::in, simplify_info::out) is det.
@@ -2566,6 +2605,8 @@
simplify_info_set_cost_delta(Delta, Info, Info ^ cost_delta := Delta).
simplify_info_set_rtti_varmaps(Rtti, Info, Info ^ rtti_varmaps := Rtti).
simplify_info_set_format_calls(FC, Info, Info ^ format_calls := FC).
+simplify_info_set_inside_duplicated_for_switch(IDFS, Info,
+ Info ^ inside_dupl_for_switch := IDFS).
simplify_info_incr_cost_delta(Incr, Info,
Info ^ cost_delta := Info ^ cost_delta + Incr).
Index: compiler/switch_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/switch_detection.m,v
retrieving revision 1.123
diff -u -b -r1.123 switch_detection.m
--- compiler/switch_detection.m 7 Apr 2006 01:32:54 -0000 1.123
+++ compiler/switch_detection.m 24 May 2006 06:33:10 -0000
@@ -468,7 +468,8 @@
is semidet.
expand_sub_disj(Var, Goal, !Cases) :-
- Goal = GoalExpr - GoalInfo,
+ Goal = GoalExpr - GoalInfo0,
+ goal_info_add_feature(duplicated_for_switch, GoalInfo0, GoalInfo),
( GoalExpr = conj(plain_conj, SubGoals) ->
expand_sub_disj_process_conj(Var, SubGoals, [], GoalInfo, !Cases)
; GoalExpr = disj(_) ->
Index: compiler/unique_modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unique_modes.m,v
retrieving revision 1.109
diff -u -b -r1.109 unique_modes.m
--- compiler/unique_modes.m 29 Mar 2006 08:07:28 -0000 1.109
+++ compiler/unique_modes.m 24 May 2006 08:00:20 -0000
@@ -130,6 +130,12 @@
;
mode_info_set_context(Context, !ModeInfo)
),
+ mode_info_get_in_dupl_for_switch(!.ModeInfo, InDuplForSwitch),
+ ( goal_info_has_feature(GoalInfo0, duplicated_for_switch) ->
+ mode_info_set_in_dupl_for_switch(yes, !ModeInfo)
+ ;
+ true
+ ),
mode_info_get_instmap(!.ModeInfo, InstMap0),
% Grab the original bag of nondet-live vars.
@@ -152,7 +158,8 @@
% and save that instmap_delta in the goal_info.
compute_goal_instmap_delta(InstMap0, GoalExpr, GoalInfo0, GoalInfo,
!ModeInfo),
- Goal = GoalExpr - GoalInfo.
+ Goal = GoalExpr - GoalInfo,
+ mode_info_set_in_dupl_for_switch(InDuplForSwitch, !ModeInfo).
make_all_nondet_live_vars_mostly_uniq(ModeInfo0, ModeInfo) :-
mode_info_get_instmap(ModeInfo0, FullInstMap0),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
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/concurrency
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/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_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/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
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/odbc
cvs diff: Diffing extras/posix
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/stream
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/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/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
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 tests
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
Index: tests/hard_coded/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mercury.options,v
retrieving revision 1.18
diff -u -b -r1.18 Mercury.options
--- tests/hard_coded/Mercury.options 20 Apr 2006 04:05:26 -0000 1.18
+++ tests/hard_coded/Mercury.options 24 May 2006 06:12:14 -0000
@@ -47,6 +47,7 @@
MCFLAGS-redoip_clobber = --no-inlining
MCFLAGS-rnd = -O6
MCFLAGS-split_c_files = --trace rep
+MCFLAGS-switch_detect = --halt-at-warn
MCFLAGS-trans_intermod_user_equality = --intermodule-optimization \
--transitive-intermodule-optimization
MCFLAGS-trans_intermod_user_equality2 = --intermodule-optimization \
Index: tests/hard_coded/switch_detect.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/switch_detect.m,v
retrieving revision 1.2
diff -u -b -r1.2 switch_detect.m
--- tests/hard_coded/switch_detect.m 28 Sep 2005 09:32:03 -0000 1.2
+++ tests/hard_coded/switch_detect.m 24 May 2006 06:13:46 -0000
@@ -1,5 +1,10 @@
% This is a test to check the proper functioning of the code in switch_detect.m
% that looks for switch unifications inside nested disjunctions.
+%
+% We also test that the compiler doesn't give a warning for the if-then-else
+% condition containing X = h(I, F): that unification is equivalent to false
+% in one arm of the generated switch and to true in the other, but it is
+% not redundant in the source code.
:- module switch_detect.
:- interface.
@@ -26,7 +31,16 @@
;
( X = g(_) ; X = h(_, _) ),
io__write(X, !IO),
- io__nl(!IO)
+ io__nl(!IO),
+ ( X = h(I, F) ->
+ io.write_string("h: ", !IO),
+ io.write_int(I, !IO),
+ io.write_string(" ", !IO),
+ io.write_float(F, !IO),
+ io.nl(!IO)
+ ;
+ true
+ )
),
read_t(Y, !IO),
(
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/recompilation
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
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: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list