From 25ab719cfaf42d196287fec2171bf3eefb845b62 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Wed, 30 Apr 2014 09:11:34 +0200 Subject: dialyzer: Introduce module local suppression of warnings The -dialyzer() attribute can be used for suppressing warnings in a module by specifying functions or warning options. It can also be used for requesting warnings in a module. --- lib/dialyzer/doc/src/dialyzer.xml | 73 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'lib/dialyzer/doc/src') diff --git a/lib/dialyzer/doc/src/dialyzer.xml b/lib/dialyzer/doc/src/dialyzer.xml index e482b1e6f8..b52c1edebf 100644 --- a/lib/dialyzer/doc/src/dialyzer.xml +++ b/lib/dialyzer/doc/src/dialyzer.xml @@ -139,7 +139,11 @@ A family of options which selectively turn on/off warnings (for help on the names of warnings use - ). + ). + Note that the options can also be given in the file with a + -dialyzer() attribute. See Requesting or Suppressing Warnings in + Source Files below for details. Do not disable the Erlang shell while running the GUI. (or ) @@ -269,6 +273,71 @@ given from the command line, so please refer to the sections above for a description of these.

+ +
+ + Requesting or Suppressing Warnings in Source Files +

+ The -dialyzer() attribute can be used for turning off + warnings in a module by specifying functions or warning options. + For example, to turn off all warnings for the function + f/0, include the following line: +

+ +-dialyzer({nowarn_function, f/0}). + +

To turn off warnings for improper lists, add the following line + to the source file: +

+ +-dialyzer(no_improper_lists). + +

The -dialyzer() attribute is allowed after function + declarations. Lists of warning options or functions are allowed: +

+ +-dialyzer([{nowarn_function, [f/0]}, no_improper_lists]). + +

+ Warning options can be restricted to functions: +

+ +-dialyzer({no_improper_lists, g/0}). + + +-dialyzer({[no_return, no_match], [g/0, h/0]}). + +

+ For help on the warning options use dialyzer -Whelp. The + options are also enumerated below (WarnOpts). +

+ +

+ The -dialyzer() attribute is not checked by the Erlang + Compiler, but by the Dialyzer itself. +

+
+ +

+ The warning option -Wrace_conditions has no effect when + set in source files. +

+
+

+ The -dialyzer() attribute can also be used for turning on + warnings. For instance, if a module has been fixed regarding + unmatched returns, adding the line +

+ +-dialyzer(unmatched_returns). + +

+ can help in assuring that no new unmatched return warnings are + introduced. +

+
+ gui() -> ok | {error, Msg} @@ -283,7 +352,7 @@ OptList :: [Option] Option :: {files, [Filename :: string()]} | {files_rec, [DirName :: string()]} - | {defines, [{Macro: atom(), Value : term()}]} + | {defines, [{Macro :: atom(), Value :: term()}]} | {from, src_code | byte_code} %% Defaults to byte_code | {init_plt, FileName :: string()} %% If changed from default | {plts, [FileName :: string()]} %% If changed from default -- cgit v1.2.3