[m-rev.] diff: pragma export and default function modes

Julien Fischer juliensf at cs.mu.OZ.AU
Tue Jan 4 18:55:29 AEDT 2005


Estimated hours taken: 0.5
Branches: main

When constructing the HLDS do not process pragma export
declarations until after the default modes for functions
have been added.  Otherwise, if we have a pragma export
declaration before a func declaration then the compiler
will emit spurious error messages about undefined modes.

compiler/make_hlds.m:
	Process pragma export decls after adding default
	function modes.

tests/valid/Mmakefile:
tests/valid/export_before_func.m:
	Test case for the above.

Julien.

Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.488
diff -u -r1.488 make_hlds.m
--- compiler/make_hlds.m	24 Dec 2004 03:54:33 -0000	1.488
+++ compiler/make_hlds.m	4 Jan 2005 07:47:50 -0000
@@ -739,9 +739,9 @@
 		% clauses and pragma c_code).
 		Pragma = import(_, _, _, _, _)
 	;
-		Pragma = export(Name, PredOrFunc, Modes, C_Function),
-		add_pragma_export(Name, PredOrFunc, Modes, C_Function,
-			Context, !Module, !IO)
+		% Handle pragma export decls later on, after default
+		% function modes have been added.
+		Pragma = export(_, _, _, _)
 	;
 			% Used for inter-module unused argument elimination.
 			% This can only appear in .opt files.
@@ -1092,6 +1092,11 @@
 		Pragma = reserve_tag(TypeName, TypeArity)
 	->
 		add_pragma_reserve_tag(TypeName, TypeArity, !.Status,
+			Context, !Module, !IO)
+	;
+		Pragma = export(Name, PredOrFunc, Modes, C_Function)
+	->
+		add_pragma_export(Name, PredOrFunc, Modes, C_Function,
 			Context, !Module, !IO)
 	;
  		% don't worry about any pragma declarations other than the
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.144
diff -u -r1.144 Mmakefile
--- tests/valid/Mmakefile	20 Oct 2004 09:45:11 -0000	1.144
+++ tests/valid/Mmakefile	4 Jan 2005 04:49:47 -0000
@@ -76,6 +76,7 @@
 	error \
 	existential_cons \
 	explicit_quant \
+	export_before_func \
 	exported_foreign_type \
 	fail_ite \
 	followcode_det_problem \
Index: tests/valid/export_before_func.m
===================================================================
RCS file: tests/valid/export_before_func.m
diff -N tests/valid/export_before_func.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/export_before_func.m	4 Jan 2005 04:49:06 -0000
@@ -0,0 +1,17 @@
+:- module export_before_func.
+
+:- interface.
+
+:- pred foo is det.
+
+:- implementation.
+
+:- import_module string, std_util.
+
+foo.
+
+:- pragma export(return_yes(in) = out, "EXPORTED_return_yes").
+:- func return_yes(string) = maybe(string).
+
+return_yes(Str) = yes(Str).
+

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