[m-rev.] for review: fix foreign type import bug

Simon Taylor stayl at cs.mu.OZ.AU
Tue Jan 13 16:28:39 AEDT 2004


On 13-Jan-2004, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> The patch below seems to be responsible for a recent warning regression,
> where compiling a module which contains `pragma export' in an LLDS grade
> results in a GCC warning: "no previous prototype for foo".
> 
> The problem seems to be that the change to mercury_compile.m was wrong.
> So I propose to back it out.

That would be the wrong fix.




Estimated hours taken: 1
Branches: main

compiler/modules.m:
	Import the current module's `.mh' file if there
	are any `:- pragma export' or `:- pragma import'
	declarations.

compiler/foreign.m:
	Add a predicate to return all foreign languages.

Index: foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.33
diff -u -u -r1.33 foreign.m
--- foreign.m	1 Jan 2004 05:57:08 -0000	1.33
+++ foreign.m	13 Jan 2004 02:41:24 -0000
@@ -221,6 +221,11 @@
 
 :- func foreign_type_language(foreign_language_type) = foreign_language.
 
+	% The `multi' mode returns all supported foreign languages.
+:- pred foreign_language(foreign_language).
+:- mode foreign_language(in) is det.
+:- mode foreign_language(out) is multi.
+
 :- implementation.
 
 :- import_module backend_libs__code_model.
@@ -844,6 +849,14 @@
 foreign_type_language(il(_)) = il.
 foreign_type_language(c(_)) = c.
 foreign_type_language(java(_)) = java.
+
+%-----------------------------------------------------------------------------%
+
+foreign_language(c).
+foreign_language(java).
+foreign_language(csharp).
+foreign_language(managed_cplusplus).
+foreign_language(il).
 
 %-----------------------------------------------------------------------------%
 
Index: modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.286
diff -u -u -r1.286 modules.m
--- modules.m	8 Jan 2004 10:01:58 -0000	1.286
+++ modules.m	13 Jan 2004 02:41:22 -0000
@@ -6930,8 +6930,13 @@
 item_needs_imports(nothing(_)) = no.
 
 :- pred item_needs_foreign_imports(item, foreign_language).
-:- mode item_needs_foreign_imports(in, out) is semidet.
+:- mode item_needs_foreign_imports(in, out) is nondet.
 
+item_needs_foreign_imports(pragma(export(_, _, _, _)), Lang) :-
+	foreign_language(Lang).
+
+	% `:- pragma import' is only supported for C.
+item_needs_foreign_imports(pragma(import(_, _, _, _, _)), c).
 item_needs_foreign_imports(Item @ type_defn(_, _, _, _, _), Lang) :-
 	Item ^ td_ctor_defn = foreign_type(ForeignType, _),
 	Lang = foreign_type_language(ForeignType).
--------------------------------------------------------------------------
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