[m-rev.] diff: disable trivial erlang warnings

Peter Wang novalazy at gmail.com
Fri Aug 31 11:05:38 AEST 2007


Estimated hours taken: 0.5
Branches: main

Add an option `--erlang-inhibit-trivial-warnings' (enabled by default) which
disables unused variable and unused local function warnings from the Erlang
compiler, because the Mercury generated Erlang code often contains both.

compiler/compile_target_code.m:
	When the option is enabled pass "+nowarn_unused_vars
	+nowarn_unused_function" to the Erlang compiler.

compiler/options.m:
doc/user_guide.texi:
	Add the new option and documentation.


Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.118
diff -u -r1.118 compile_target_code.m
--- compiler/compile_target_code.m	20 Aug 2007 05:57:22 -0000	1.118
+++ compiler/compile_target_code.m	29 Aug 2007 01:22:59 -0000
@@ -889,12 +889,22 @@
     globals.io_lookup_string_option(erlang_compiler, ErlangCompiler, !IO),
     globals.io_lookup_accumulating_option(erlang_flags, ErlangFlagsList0, !IO),
     globals.io_lookup_bool_option(erlang_native_code, ErlangNativeCode, !IO),
+    globals.io_lookup_bool_option(erlang_inhibit_trivial_warnings,
+        ErlangInhibitTrivialWarnings, !IO),
     (
         ErlangNativeCode = yes,
-        ErlangFlagsList = ["+native" | ErlangFlagsList0]
+        ErlangFlagsList1 = ["+native" | ErlangFlagsList0]
     ;
         ErlangNativeCode = no,
-        ErlangFlagsList = ErlangFlagsList0
+        ErlangFlagsList1 = ErlangFlagsList0
+    ),
+    (
+        ErlangInhibitTrivialWarnings = yes,
+        ErlangFlagsList = ["+nowarn_unused_vars", "+nowarn_unused_function"
+            | ErlangFlagsList1]
+    ;
+        ErlangInhibitTrivialWarnings = no,
+        ErlangFlagsList = ErlangFlagsList1
     ),
     ERLANGFLAGS = string.join_list(" ", ErlangFlagsList),
 
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.582
diff -u -r1.582 options.m
--- compiler/options.m	8 Aug 2007 16:41:21 -0000	1.582
+++ compiler/options.m	29 Aug 2007 01:22:59 -0000
@@ -725,6 +725,7 @@
     ;       erlang_include_directory
     ;       erlang_object_file_extension
     ;       erlang_native_code
+    ;       erlang_inhibit_trivial_warnings
 
     % Link options
     ;       output_file_name
@@ -1497,7 +1498,8 @@
     quoted_erlang_flag                  -   string_special,
     erlang_include_directory            -   accumulating([]),
     erlang_object_file_extension        -   string(".beam"),
-    erlang_native_code                  -   bool(no)
+    erlang_native_code                  -   bool(no),
+    erlang_inhibit_trivial_warnings     -   bool(yes)
 ]).
 option_defaults_2(link_option, [
     % Link Options
@@ -2324,6 +2326,8 @@
 long_option("erlang-include-dir",       erlang_include_directory).
 long_option("erlang-object-file-extension", erlang_object_file_extension).
 long_option("erlang-native-code",   erlang_native_code).
+long_option("erlang-inhibit-trivial-warnings",
+                                    erlang_inhibit_trivial_warnings).
 
 % link options
 long_option("output-file",          output_file_name).
@@ -4735,10 +4739,13 @@
         "\tAppend <dir> to the list of directories to be searched for",
         "\tErlang header files (.hrl).",
         "--erlang-native-code",
-        "\tAdd `+native' to the start of flags passed to the Erlang compiler.",
+        "\tAdd `+native' to the list of flags passed to the Erlang compiler.",
         "\tCancelled out by `--no-erlang-native-code' so it's useful when you",
         "\twish to enable native code generation for all modules except for",
-        "\ta select few."
+        "\ta select few.",
+        "--no-erlang-inhibit-trivial-warnings",
+        "\tDo not add `+nowarn_unused_vars +nowarn_unused_function' to the",
+        "\tlist of flags passed to the Erlang compiler."
 
         % --erlang-object-file-extension is deliberately not documented.
         % It is not fully implemented and not very useful.
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.541
diff -u -r1.541 user_guide.texi
--- doc/user_guide.texi	17 Aug 2007 02:04:14 -0000	1.541
+++ doc/user_guide.texi	29 Aug 2007 01:22:59 -0000
@@ -8998,6 +8998,13 @@
 wish to enable native code generation for all modules except for
 a select few.
 
+ at sp 1
+ at item --no-erlang-inhibit-trivial-warnings
+ at findex --no-erlang-inhibit-trivial-warnings
+ at cindex Erlang compiler options
+Do not add @samp{+nowarn_unused_vars +nowarn_unused_function} to the
+list of flags passed to the Erlang compiler.
+
 @c This option is not fully implemented and not very useful.
 @c @sp 1
 @c @item --erlang-object-file-extension @var{extension}

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