aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test/warnings_SUITE.erl
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2014-03-08 02:31:53 +0100
committerAnthony Ramine <[email protected]>2014-03-10 02:37:10 +0100
commit4777f33ece33aaaa5066730b950f185cbd5ae816 (patch)
treedb57597f62d5c6eda64f12f6274900655e2ac194 /lib/compiler/test/warnings_SUITE.erl
parent870737ab657433c5e8751255fe3c4d298202d142 (diff)
downloadotp-4777f33ece33aaaa5066730b950f185cbd5ae816.tar.gz
otp-4777f33ece33aaaa5066730b950f185cbd5ae816.tar.bz2
otp-4777f33ece33aaaa5066730b950f185cbd5ae816.zip
Properly handle redundant boolean clauses in sys_core_fold
Boolean case expressions with redundant clauses could make the compiler crash: case X == 0 of false -> no; false -> no; true -> yes end. Reported-by: Ulf Norell
Diffstat (limited to 'lib/compiler/test/warnings_SUITE.erl')
-rw-r--r--lib/compiler/test/warnings_SUITE.erl22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/compiler/test/warnings_SUITE.erl b/lib/compiler/test/warnings_SUITE.erl
index f63299ea35..de56a59e12 100644
--- a/lib/compiler/test/warnings_SUITE.erl
+++ b/lib/compiler/test/warnings_SUITE.erl
@@ -38,7 +38,7 @@
-export([pattern/1,pattern2/1,pattern3/1,pattern4/1,
guard/1,bad_arith/1,bool_cases/1,bad_apply/1,
files/1,effect/1,bin_opt_info/1,bin_construction/1, comprehensions/1,
- maps/1]).
+ maps/1,redundant_boolean_clauses/1]).
% Default timetrap timeout (set in init_per_testcase).
-define(default_timeout, ?t:minutes(2)).
@@ -62,7 +62,8 @@ groups() ->
[{p,test_lib:parallel(),
[pattern,pattern2,pattern3,pattern4,guard,
bad_arith,bool_cases,bad_apply,files,effect,
- bin_opt_info,bin_construction,comprehensions,maps]}].
+ bin_opt_info,bin_construction,comprehensions,maps,
+ redundant_boolean_clauses]}].
init_per_suite(Config) ->
Config.
@@ -201,6 +202,8 @@ pattern4(Config) when is_list(Config) ->
[nowarn_unused_vars],
{warnings,
[{9,sys_core_fold,no_clause_match},
+ {11,sys_core_fold,nomatch_shadow},
+ {15,sys_core_fold,nomatch_shadow},
{18,sys_core_fold,no_clause_match},
{23,sys_core_fold,no_clause_match},
{33,sys_core_fold,no_clause_match}
@@ -573,6 +576,21 @@ maps(Config) when is_list(Config) ->
run(Config, Ts),
ok.
+redundant_boolean_clauses(Config) when is_list(Config) ->
+ Ts = [{redundant_boolean_clauses,
+ <<"
+ t(X) ->
+ case X == 0 of
+ false -> no;
+ false -> no;
+ true -> yes
+ end.
+ ">>,
+ [],
+ {warnings,[{5,sys_core_fold,nomatch_shadow}]}}],
+ run(Config, Ts),
+ ok.
+
%%%
%%% End of test cases.
%%%