[m-dev.] diff: fix bug in specialization of comparisons

Simon Taylor stayl at cs.mu.OZ.AU
Tue Oct 31 13:04:20 AEDT 2000



Estimated hours taken: 0.5

Fix a bug which caused references to private_builtin__unsafe_type_cast
to appear in the generated code, causing link errors.

compiler/higher_order.m:
	The builtin_state argument of a call to
	`private_builtin__unsafe_type_cast' must
	be `inline_builtin'.

tests/hard_coded/Mmakefile:
tests/hard_coded/compare_spec.m:
tests/hard_coded/compare_spec.exp:
	Test case.


Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.79
diff -u -u -r1.79 higher_order.m
--- compiler/higher_order.m	2000/10/27 05:01:12	1.79
+++ compiler/higher_order.m	2000/10/30 14:45:20
@@ -2066,7 +2066,7 @@
 	instmap_delta_from_assoc_list([CastArg - ground(shared, none)],
 		InstMapDelta),
 	goal_info_init(NonLocals, InstMapDelta, det, GoalInfo),
-	Goal = call(PredId, ProcId, [Arg, CastArg], not_builtin,
+	Goal = call(PredId, ProcId, [Arg, CastArg], inline_builtin,
 		no, qualified(MercuryBuiltin, "unsafe_type_cast")) - GoalInfo.
 
 :- pred unwrap_no_tag_arg((type)::in, sym_name::in, prog_var::in,
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.96
diff -u -u -r1.96 Mmakefile
--- tests/hard_coded/Mmakefile	2000/10/27 06:42:59	1.96
+++ tests/hard_coded/Mmakefile	2000/10/31 01:18:00
@@ -20,6 +20,7 @@
 	checked_nondet_tailcall \
 	closure_extension \
 	common_type_cast \
+	compare_spec \
 	construct \
 	copy_pred \
 	curry \
Index: tests/hard_coded/compare_spec.exp
===================================================================
RCS file: compare_spec.exp
diff -N compare_spec.exp
--- /dev/null	Tue Oct 31 12:55:42 2000
+++ compare_spec.exp	Tue Oct 31 12:55:01 2000
@@ -0,0 +1 @@
+succeeded
Index: tests/hard_coded/compare_spec.m
===================================================================
RCS file: compare_spec.m
diff -N compare_spec.m
--- /dev/null	Tue Oct 31 12:55:42 2000
+++ compare_spec.m	Tue Oct 31 12:54:18 2000
@@ -0,0 +1,32 @@
+% Test the transformation of comparisons of enumerations into
+% integer comparisons.
+%
+% With the compiler of 31/10/2000, this test case failed
+% to link due to references to private_builtin__unsafe_type_cast
+% in the generated code (calls to private_builtin__unsafe_type_cast
+% should be generated inline).
+:- module compare_spec.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module bool.
+
+main -->
+	( { compare_bool } ->
+		io__write_string("failed\n")
+	;
+		io__write_string("succeeded\n")
+	).
+
+:- pred compare_bool is semidet.
+
+compare_bool :-
+        compare(Result, yes, no),
+        Result = (=).
+
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list