aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2014-03-03 15:27:09 +0100
committerHans Bolinder <[email protected]>2014-03-04 12:08:16 +0100
commit774955d0d2a44fa8ac5943a14516d54db2b8f6d5 (patch)
tree147bcef3d834180b8bc7ed1174fcd113022e19f7 /lib
parente2910a4fc3c0e8f70fef5578225edc6e36d6fbe7 (diff)
downloadotp-774955d0d2a44fa8ac5943a14516d54db2b8f6d5.tar.gz
otp-774955d0d2a44fa8ac5943a14516d54db2b8f6d5.tar.bz2
otp-774955d0d2a44fa8ac5943a14516d54db2b8f6d5.zip
Introduce compiler option 'nowarn_deprecated_type'
The deprecation of the built-in types dict/0 and so on had as side-effect that it was impossible to switch to dict:dict/2 and so on without getting warnings either in the the previous release (R16B) or the current one (17.0). By including the attribute -compile(nowarn_deprecated_type). in an Erlang source file warnings about deprecated types can be avoided in 17.0. The option can also be given as a compiler flag: erlc +nowarn_deprecated_type file.erl
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/doc/src/compile.xml10
-rw-r--r--lib/stdlib/src/erl_lint.erl6
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl23
3 files changed, 36 insertions, 3 deletions
diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml
index c66c8ea4bf..5fccdcdcb5 100644
--- a/lib/compiler/doc/src/compile.xml
+++ b/lib/compiler/doc/src/compile.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1996</year><year>2013</year>
+ <year>1996</year><year>2014</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -551,6 +551,14 @@ module.beam: module.erl \
<c>{Module,Name,Arity}</c> or a list of such tuples.</p>
</item>
+ <tag><c>nowarn_deprecated_type</c></tag>
+ <item>
+ <p>Turns off warnings for uses of deprecated types. By
+ default (<c>warn_deprecated_type</c>), warnings are
+ emitted for every use of a type known by the compiler
+ to be deprecated.</p>
+ </item>
+
<tag><c>warn_obsolete_guard</c></tag>
<item>
<p>Causes warnings to be emitted for calls to old type
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl
index 603808328e..1fe0bd5896 100644
--- a/lib/stdlib/src/erl_lint.erl
+++ b/lib/stdlib/src/erl_lint.erl
@@ -508,6 +508,9 @@ start(File, Opts) ->
{deprecated_function,
bool_option(warn_deprecated_function, nowarn_deprecated_function,
true, Opts)},
+ {deprecated_type,
+ bool_option(warn_deprecated_type, nowarn_deprecated_type,
+ true, Opts)},
{obsolete_guard,
bool_option(warn_obsolete_guard, nowarn_obsolete_guard,
true, Opts)},
@@ -2646,7 +2649,8 @@ check_type({type, La, TypeName, Args}, SeenVars, St) ->
St1 = case is_var_arity_type(TypeName) of
true -> St;
false ->
- Obsolete = obsolete_builtin_type(TypePair),
+ Obsolete = (is_warn_enabled(deprecated_type, St)
+ andalso obsolete_builtin_type(TypePair)),
IsObsolete =
case Obsolete of
{deprecated, Repl, _} when element(1, Repl) =/= Module ->
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 68bea539a8..8754677466 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -3243,7 +3243,7 @@ bin_syntax_errors(Config) ->
ok.
predef(doc) ->
- "Predefined types: array(), digraph(), and so on";
+ "OTP-10342: Predefined types: array(), digraph(), and so on";
predef(suite) -> [];
predef(Config) when is_list(Config) ->
W = get_compilation_warnings(Config, "predef", []),
@@ -3258,6 +3258,27 @@ predef(Config) when is_list(Config) ->
{37,erl_lint,{Tag,{queue,0},{queue,queue,1},"OTP 18.0"}},
{42,erl_lint,{Tag,{set,0},{sets,set,1},"OTP 18.0"}},
{47,erl_lint,{Tag,{tid,0},{ets,tid},"OTP 18.0"}}] = W2,
+ Ts = [{otp_10342_1,
+ <<"-compile(nowarn_deprecated_type).
+
+ -spec t(dict()) -> non_neg_integer().
+
+ t(D) ->
+ erlang:phash2(D, 3000).
+ ">>,
+ {[nowarn_unused_function]},
+ []},
+ {otp_10342_2,
+ <<"-spec t(dict()) -> non_neg_integer().
+
+ t(D) ->
+ erlang:phash2(D, 3000).
+ ">>,
+ {[nowarn_unused_function]},
+ {warnings,[{1,erl_lint,
+ {deprecated_builtin_type,{dict,0},{dict,dict,2},
+ "OTP 18.0"}}]}}],
+ [] = run(Config, Ts),
ok.
run(Config, Tests) ->