[m-rev.] diff: bug in outputting mercury and foreign type declarations in .opt file

Peter Ross pro at missioncriticalit.com
Tue Dec 10 22:34:40 AEDT 2002


Hi,

Release branch?  I was thinking it should go on, but after 0.11 has been
released.

I have built a test case for this, but the problems only shows up when you
build the .opt file in say a C grade and use the .opt file when building in the
IL grade.  This can be tested by setting the grade in EXTRA_MCOIFLAGS, but
where should I put this test case?

===================================================================


Estimated hours taken: 1
Branches: main

Fix a bug where types which where defined as a C foreign_type and a
Mercury type where not having the Mercury type definition placed in
the .opt file.

compiler/make_hlds.m:
	Don't ignore Mercury definitions of types which have a
	foreign_type representation when we are making the .opt file.


Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.427
diff -u -r1.427 make_hlds.m
--- compiler/make_hlds.m	22 Nov 2002 13:41:47 -0000	1.427
+++ compiler/make_hlds.m	10 Dec 2002 11:05:53 -0000
@@ -2076,6 +2076,8 @@
 		{ Body_2 \= abstract_type }
 	->
 		globals__io_get_target(Target),
+		globals__io_lookup_bool_option(make_optimization_interface,
+				MakeOptInt),
 	  	(
 			% then if this definition was abstract, ignore it
 			% (but update the status of the old defn if necessary)
@@ -2093,8 +2095,8 @@
 				module_info_set_types(Module0, Types, Module)
 			}
 		;
-			{ merge_foreign_type_bodies(Target, Body, Body_2,
-				NewBody) }
+			{ merge_foreign_type_bodies(Target, MakeOptInt,
+					Body, Body_2, NewBody) }
 		->
 			(
 				{ check_foreign_type_visibility(OrigStatus,
@@ -2334,12 +2336,17 @@
 			TypeCheckOnly, ErrorCheckOnly, OutputGradeString],
 			NotGeneratingCode) }.
 
-:- pred merge_foreign_type_bodies(compilation_target::in, hlds_type_body::in,
+:- pred merge_foreign_type_bodies(compilation_target::in,
+		bool::in, hlds_type_body::in,
 		hlds_type_body::in, hlds_type_body::out) is semidet.
 
 	% Ignore Mercury definitions if we've got a foreign type
-	% declaration suitable for this back-end.
-merge_foreign_type_bodies(Target, foreign_type(ForeignTypeBody0),
+	% declaration suitable for this back-end and we aren't making the
+	% optimization interface.  We need to keep the Mercury definition
+	% if we are making the optimization interface so that it gets
+	% output in the .opt file.
+merge_foreign_type_bodies(Target, MakeOptInterface,
+		foreign_type(ForeignTypeBody0),
 		Body1 @ du_type(_, _, _, _, MaybeForeignTypeBody1), Body) :-
 	( MaybeForeignTypeBody1 = yes(ForeignTypeBody1)
 	; MaybeForeignTypeBody1 = no,
@@ -2347,15 +2354,19 @@
 	),
 	merge_foreign_type_bodies_2(ForeignTypeBody0,
 		ForeignTypeBody1, ForeignTypeBody),
-	( have_foreign_type_for_backend(Target, ForeignTypeBody, yes) ->
+	(
+		have_foreign_type_for_backend(Target, ForeignTypeBody, yes),
+		MakeOptInterface = no
+	->
 		Body = foreign_type(ForeignTypeBody)
 	;
 		Body = Body1 ^ du_type_is_foreign_type := yes(ForeignTypeBody)
 	).
-merge_foreign_type_bodies(Target, Body0 @ du_type(_, _, _, _, _),
+merge_foreign_type_bodies(Target, MakeOptInterface,
+		Body0 @ du_type(_, _, _, _, _),
 		Body1 @ foreign_type(_), Body) :-
-	merge_foreign_type_bodies(Target, Body1, Body0, Body).
-merge_foreign_type_bodies(_, foreign_type(Body0), foreign_type(Body1),
+	merge_foreign_type_bodies(Target, MakeOptInterface, Body1, Body0, Body).
+merge_foreign_type_bodies(_, _, foreign_type(Body0), foreign_type(Body1),
 		foreign_type(Body)) :-
 	merge_foreign_type_bodies_2(Body0, Body1, Body).
 

--------------------------------------------------------------------------
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