[m-rev.] for review: fix singleton variable warning problem
Peter Ross
pro at missioncriticalit.com
Fri May 31 02:41:25 AEST 2002
On Wed, May 29, 2002 at 03:34:23AM +1000, Simon Taylor wrote:
> This isn't an acceptable fix.
>
How about this.
===================================================================
Estimated hours taken: 4
Branches: main
compiler/make_hlds.m:
Avoid the problem with a variable with a non anonymous name in a
Mercury clause is renamed to an anonymous variable name by
interaction merging in the varset of a pragma foreign_code, and
hence causes spurious warnings.
tests/valid/Mmakefile:
tests/valid/no_warn_singleton.m:
A test case.
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/make_hlds.m,v
retrieving revision 1.411
diff -u -r1.411 make_hlds.m
--- compiler/make_hlds.m 9 May 2002 16:30:55 -0000 1.411
+++ compiler/make_hlds.m 30 May 2002 16:36:08 -0000
@@ -5644,9 +5644,13 @@
io__write_string(" in the argument list.\n"),
io__set_exit_status(1)
;
- % merge the varsets of the proc and the new pragma_c_code
+ % Merge the varsets of the proc and the new foreign_proc.
+ % Note that we discard the names of the foreign_proc as
+ % this avoids problems with anonymous variables and
+ % implementations in Mercury.
{
- varset__merge_subst(VarSet0, PVarSet, VarSet1, Subst),
+ varset__merge_subst_without_names(VarSet0,
+ PVarSet, VarSet1, Subst),
map__apply_to_list(Args0, Subst, TermArgs),
term__term_list_to_var_list(TermArgs, Args),
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/Mmakefile,v
retrieving revision 1.102
diff -u -r1.102 Mmakefile
--- tests/valid/Mmakefile 14 May 2002 14:34:41 -0000 1.102
+++ tests/valid/Mmakefile 30 May 2002 12:49:36 -0000
@@ -135,6 +135,7 @@
nasty_func_test.m \
nested_mod_type_bug.m \
nondet_live.m \
+ no_warn_singleton.m \
parsing_bug_main.m \
pred_with_no_modes.m \
qualified_cons_id.m \
@@ -299,6 +300,7 @@
MCFLAGS-livevals_seq = -O5 --opt-space
MCFLAGS-middle_rec_labels = --middle-rec --no-follow-vars
MCFLAGS-mostly_uniq_mode_inf = --infer-all
+MCFLAGS-no_warn_singleton = --halt-at-warn
MCFLAGS-pred_with_no_modes = --infer-all
MCFLAGS-quantifier_warning = --halt-at-warn
MCFLAGS-simplify_bug = -O-1
Index: tests/valid/no_warn_singleton.m
===================================================================
RCS file: tests/valid/no_warn_singleton.m
diff -N tests/valid/no_warn_singleton.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/valid/no_warn_singleton.m 30 May 2002 09:20:53 -0000
@@ -0,0 +1,17 @@
+% Check that we don't warn about _IO0 and _IO being used more than once.
+:- module no_warn_singleton.
+
+:- interface.
+
+:- import_module io.
+
+:- pred p(int::out, io::di, io::uo) is det.
+
+:- implementation.
+
+:- pragma foreign_proc("C", p(X::out, _IO0::di, _IO::uo),
+ [will_not_call_mercury, promise_pure], "
+ X = 5;
+").
+
+p(5) --> [].
--------------------------------------------------------------------------
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