[m-rev.] for review: avoid spurious detism warnings with --intermod-opt

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Dec 3 18:06:22 AEDT 2007


For review by anyone.

Estimated hours taken: 1
Branches: main

Fix an annoyance:  the compiler was emitting warnings for opt imported
predicates that it had inferred were erroneous.  Suppress this behaviour
since there is not much the writer of the importing module can do about it.
(The writer could enable --no-warn-inferred-erroneous for the importing
module but that may suppress warnings for which something useful could
potentially be done.)

Additionally the context attached to the spurious warning indicated that
it was occurring inside a .int file, which is a potential source of 
confusion in itself.

compiler/det_report.m:
 	Don't warn about opt imported predicates whose determinism is inferred
 	to be erroneous.

tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/opt_det_warn.m:
tests/valid/opt_det_warn2.m:
 	Test case for the above.

Julien.

Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.139
diff -u -r1.139 det_report.m
--- compiler/det_report.m	23 Nov 2007 07:34:59 -0000	1.139
+++ compiler/det_report.m	3 Dec 2007 07:04:47 -0000
@@ -220,7 +220,13 @@
                  ;
                      WarnAboutInferredErroneous = no,
                      InferredDetism \= detism_erroneous
-                )
+                ),
+
+                % Only warn about predicates that are defined in this module.
+                % This avoids warnings being emitted for opt_imported 
+                % predicates.
+                pred_info_get_import_status(PredInfo0, ImportStatus),
+                status_defined_in_this_module(ImportStatus) = yes
              ->
                  Message = "warning: determinism declaration " ++
                      "could be tighter.\n",
Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.41
diff -u -r1.41 Mercury.options
--- tests/valid/Mercury.options	31 Oct 2007 13:27:23 -0000	1.41
+++ tests/valid/Mercury.options	3 Dec 2007 07:04:47 -0000
@@ -89,6 +89,8 @@
  MCFLAGS-mostly_uniq_mode_inf	= --infer-all
  MCFLAGS-mpj6			= --infer-all
  MCFLAGS-no_warn_obsolete	= --no-warn-obsolete
+MCFLAGS-opt_det_warn            = --intermodule-optimization --halt-at-warn
+MCFLAGS-opt_det_warn2		= --intermodule-optimization --halt-at-warn --no-warn-inferred-erroneous
  MCFLAGS-par_dupelim		= --optimize-dups
  MCFLAGS-par_saved_const 	= -O3 --optimize-saved-vars-const
  MCFLAGS-pred_with_no_modes	= --infer-all
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.202
diff -u -r1.202 Mmakefile
--- tests/valid/Mmakefile	23 Nov 2007 03:47:40 -0000	1.202
+++ tests/valid/Mmakefile	3 Dec 2007 07:04:47 -0000
@@ -175,6 +175,7 @@
  	nested_module_bug \
  	no_warn_obsolete \
  	nondet_live \
+	opt_det_warn \
  	overloading \
  	param_mode_bug \
  	parsing_bug_main \
Index: tests/valid/opt_det_warn.m
===================================================================
RCS file: tests/valid/opt_det_warn.m
diff -N tests/valid/opt_det_warn.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/opt_det_warn.m	3 Dec 2007 07:04:47 -0000
@@ -0,0 +1,10 @@
+% Check that we don't emit inferred erroneous warnings for opt imported
+% predicates.
+:- module opt_det_warn.
+:- interface.
+:- import_module io.
+:- pred main(io::di, io::uo) is det.
+:- implementation.
+:- import_module opt_det_warn2.
+main(!IO) :-
+	foo(!IO).
Index: tests/valid/opt_det_warn2.m
===================================================================
RCS file: tests/valid/opt_det_warn2.m
diff -N tests/valid/opt_det_warn2.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/opt_det_warn2.m	3 Dec 2007 07:04:47 -0000
@@ -0,0 +1,8 @@
+:- module opt_det_warn2.
+:- interface.
+:- import_module io.
+:- pred foo(io::di, io::uo) is det.
+:- implementation.
+:- import_module exception.
+foo(_, _) :-
+	throw("help!").

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list