[m-rev.] for review: fix singleton variable warning problem
Peter Ross
pro at missioncriticalit.com
Wed May 29 03:07:38 AEST 2002
Hi,
For Simon to review.
This solution isn't very elegant but I couldn't think of a better way to fix
it, suggestions welcome.
===================================================================
Estimated hours taken: 4
Branches: main
Avoid a bug where predicates defined in both Mercury and a foreign
language were issuing warnings about underscore variables occuring
more than once. This is because if the foreign clause appears first
than its varset is used for the names of the variables and hence a
variable could be given an underscore name.
mcpp/compiler/make_hlds.m:
If a clause has foreign clauses don't check for singleton
variables.
tests/hard_coded/Mmakefile:
tests/hard_coded/no_warn_singleton.exp:
tests/hard_coded/no_warn_singleton.m:
A test case.
Index: mcpp/compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.411
diff -u -r1.411 make_hlds.m
--- mcpp/compiler/make_hlds.m 9 May 2002 16:30:55 -0000 1.411
+++ mcpp/compiler/make_hlds.m 28 May 2002 17:02:47 -0000
@@ -3887,7 +3887,10 @@
module_info_set_predicate_table(ModuleInfo3, PredicateTable,
ModuleInfo)
},
- ( { Status \= opt_imported } ->
+ (
+ { Status \= opt_imported },
+ { Clauses ^ have_foreign_clauses = no }
+ ->
% warn about singleton variables
maybe_warn_singletons(VarSet,
PredOrFunc - PredName/Arity, ModuleInfo, Goal),
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.144
diff -u -r1.144 Mmakefile
--- tests/hard_coded/Mmakefile 3 Mar 2002 13:45:47 -0000 1.144
+++ tests/hard_coded/Mmakefile 28 May 2002 17:02:47 -0000
@@ -88,6 +88,7 @@
name_mangling \
no_fully_strict \
no_inline \
+ no_warn_singleton \
nondet_ctrl_vn \
nondet_copy_out \
nullary_ho_func \
@@ -238,6 +239,7 @@
MCFLAGS-intermod_type_qual2 = --intermodule-optimization
MCFLAGS-intermod_multimode = --intermodule-optimization
MCFLAGS-intermod_multimode_main = --intermodule-optimization
+MCFLAGS-no_warn_singleton = --halt-at-warn
MCFLAGS-nondet_copy_out = --no-inlining --nondet-copy-out
MCFLAGS-redoip_clobber = --no-inlining
MCFLAGS-rnd = -O6
Index: tests/hard_coded/no_warn_singleton.exp
===================================================================
RCS file: tests/hard_coded/no_warn_singleton.exp
diff -N tests/hard_coded/no_warn_singleton.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/no_warn_singleton.exp 28 May 2002 17:02:47 -0000
@@ -0,0 +1 @@
+5
Index: tests/hard_coded/no_warn_singleton.m
===================================================================
RCS file: tests/hard_coded/no_warn_singleton.m
diff -N tests/hard_coded/no_warn_singleton.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/no_warn_singleton.m 28 May 2002 17:02:47 -0000
@@ -0,0 +1,25 @@
+% A regression test to ensure that we don't get warnings about the variables
+% _IO0 and _IO occuring more than once.
+:- module no_warn_singleton.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+main -->
+ f(X),
+ io__write_int(X),
+ io__nl.
+
+:- pred f(int::out, io::di, io::uo) is det.
+
+:- pragma foreign_proc("C", f(X::out, _IO0::di, _IO::uo),
+ [will_not_call_mercury, promise_pure], "
+ X = 5;
+").
+
+f(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