diff options
author | Björn Gustavsson <[email protected]> | 2010-03-16 16:13:54 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-03-22 18:20:13 +0100 |
commit | d179c1522c73de550bce45c7f5d5055e04b93f32 (patch) | |
tree | 28fe63f24211516ce9141b31382a3911dd71ed3b | |
parent | bba60738a4de2528a361d815895191e8e0efd529 (diff) | |
download | otp-d179c1522c73de550bce45c7f5d5055e04b93f32.tar.gz otp-d179c1522c73de550bce45c7f5d5055e04b93f32.tar.bz2 otp-d179c1522c73de550bce45c7f5d5055e04b93f32.zip |
compiler: Don't support the no_binaries option
The no_binaries option terminates the compiler with an error
if any bit syntax is used in the module being compiled.
(It used to be implied by the removed r11 option.)
-rw-r--r-- | lib/compiler/src/compile.erl | 3 | ||||
-rw-r--r-- | lib/compiler/src/v3_core.erl | 46 | ||||
-rw-r--r-- | lib/compiler/test/error_SUITE.erl | 35 | ||||
-rw-r--r-- | lib/compiler/test/test_lib.erl | 1 |
4 files changed, 14 insertions, 71 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index eaec5a6d78..5017fd2c23 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -164,9 +164,6 @@ expand_opt(return, Os) -> [return_errors,return_warnings|Os]; expand_opt({debug_info_key,_}=O, Os) -> [encrypt_debug_info,O|Os]; -expand_opt(no_binaries=O, Os) -> - %%Turn off the entire type optimization pass. - [no_topt,O|Os]; expand_opt(no_float_opt, Os) -> %%Turn off the entire type optimization pass. [no_topt|Os]; diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl index dfe15de4ff..8b04969b05 100644 --- a/lib/compiler/src/v3_core.erl +++ b/lib/compiler/src/v3_core.erl @@ -213,10 +213,7 @@ clause({clause,Lc,H0,G0,B0}, St0) -> catch throw:nomatch -> St = add_warning(Lc, nomatch, St0), - {noclause,St}; %Bad pattern - throw:no_binaries -> - St = add_error(Lc, no_binaries, St0), - {noclause,St} + {noclause,St} %Bad pattern end. clause_arity({clause,_,H0,_,_}) -> length(H0). @@ -496,22 +493,18 @@ expr({tuple,L,Es0}, St0) -> {Es1,Eps,St1} = safe_list(Es0, St0), A = lineno_anno(L, St1), {ann_c_tuple(A, Es1),Eps,St1}; -expr({bin,L,Es0}, #core{opts=Opts}=St0) -> - St1 = case member(no_binaries, Opts) of - false -> St0; - true -> add_error(L, no_binaries, St0) - end, - try expr_bin(Es0, lineno_anno(L, St1), St1) of +expr({bin,L,Es0}, St0) -> + try expr_bin(Es0, lineno_anno(L, St0), St0) of {_,_,_}=Res -> Res catch throw:bad_binary -> - St2 = add_warning(L, bad_binary, St1), - LineAnno = lineno_anno(L, St2), + St = add_warning(L, bad_binary, St0), + LineAnno = lineno_anno(L, St), As = [#c_literal{anno=LineAnno,val=badarg}], {#icall{anno=#a{anno=LineAnno}, %Must have an #a{} module=#c_literal{anno=LineAnno,val=erlang}, name=#c_literal{anno=LineAnno,val=error}, - args=As},[],St2} + args=As},[],St} end; expr({block,_,Es0}, St0) -> %% Inline the block directly. @@ -618,10 +611,6 @@ expr({match,L,P0,E0}, St0) -> St = add_warning(L, nomatch, St2), {#icase{anno=#a{anno=Lanno}, args=[E2],clauses=[],fc=Fc},Eps,St}; - no_binaries -> - St = add_error(L, no_binaries, St2), - {#icase{anno=#a{anno=Lanno}, - args=[E2],clauses=[],fc=Fc},Eps,St}; Other when not is_atom(Other) -> {#imatch{anno=#a{anno=Lanno},pat=P2,arg=E2,fc=Fc},Eps,St2} end; @@ -1443,15 +1432,10 @@ pattern({cons,L,H,T}, St) -> ann_c_cons(lineno_anno(L, St), pattern(H, St), pattern(T, St)); pattern({tuple,L,Ps}, St) -> ann_c_tuple(lineno_anno(L, St), pattern_list(Ps, St)); -pattern({bin,L,Ps}, #core{opts=Opts}=St) -> - case member(no_binaries, Opts) of - false -> - %% We don't create a #ibinary record here, since there is - %% no need to hold any used/new annotations in a pattern. - #c_binary{anno=lineno_anno(L, St),segments=pat_bin(Ps, St)}; - true -> - throw(no_binaries) - end; +pattern({bin,L,Ps}, St) -> + %% We don't create a #ibinary record here, since there is + %% no need to hold any used/new annotations in a pattern. + #c_binary{anno=lineno_anno(L, St),segments=pat_bin(Ps, St)}; pattern({match,_,P1,P2}, St) -> pat_alias(pattern(P1, St), pattern(P2, St)). @@ -2116,21 +2100,15 @@ is_simp_bin(Es) -> %%% Handling of warnings. %%% --type err_desc() :: 'bad_binary' | 'no_binaries' | 'nomatch'. +-type err_desc() :: 'bad_binary' | 'nomatch'. -spec format_error(err_desc()) -> nonempty_string(). format_error(nomatch) -> "pattern cannot possibly match"; format_error(bad_binary) -> - "binary construction will fail because of a type mismatch"; -format_error(no_binaries) -> - "bit syntax is not allowed to be used when compatibility with a previous " - "version has been requested". + "binary construction will fail because of a type mismatch". add_warning(Line, Term, #core{ws=Ws,file=[{file,File}]}=St) when Line >= 0 -> St#core{ws=[{File,[{location(Line),?MODULE,Term}]}|Ws]}; add_warning(_, _, St) -> St. - -add_error(Line, Term, #core{es=Es,file=[{file,File}]}=St) -> - St#core{es=[{File,[{location(abs_line(Line)),?MODULE,Term}]}|Es]}. diff --git a/lib/compiler/test/error_SUITE.erl b/lib/compiler/test/error_SUITE.erl index cdd2434b25..4530313bb0 100644 --- a/lib/compiler/test/error_SUITE.erl +++ b/lib/compiler/test/error_SUITE.erl @@ -21,11 +21,11 @@ -include("test_server.hrl"). -export([all/1, - head_mismatch_line/1,r11b_binaries/1,warnings_as_errors/1]). + head_mismatch_line/1,warnings_as_errors/1]). all(suite) -> test_lib:recompile(?MODULE), - [head_mismatch_line,r11b_binaries,warnings_as_errors]. + [head_mismatch_line,warnings_as_errors]. %% Tests that a head mismatch is reported on the correct line (OTP-2125). head_mismatch_line(Config) when is_list(Config) -> @@ -42,37 +42,6 @@ get_compilation_errors(Config, Filename) -> ?line {error, [{_Name, E}|_], []} = compile:file(File, [return_errors]), E. -r11b_binaries(Config) when is_list(Config) -> - Ts = [{r11b_binaries, - <<" - t1(Bin) -> - case Bin of - _ when size(Bin) > 20 -> erlang:error(too_long); - <<_,T/binary>> -> t1(T); - <<>> -> ok - end. - - t2(<<_,T/bytes>>) -> - split_binary(T, 4). - - t3(X) -> - <<42,X/binary>>. - - t4(X) -> - <<N:32>> = X, - N. - ">>, - [r11], - {error, - [{5,v3_core,no_binaries}, - {6,v3_core,no_binaries}, - {9,v3_core,no_binaries}, - {13,v3_core,no_binaries}, - {16,v3_core,no_binaries}], - []} }], - ?line [] = run(Config, Ts), - ok. - warnings_as_errors(Config) when is_list(Config) -> Ts = [{warnings_as_errors, <<" diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index 382839d919..43d2cacd59 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -57,7 +57,6 @@ opt_opts(Mod) -> (no_new_apply) -> true; (no_gc_bifs) -> true; (no_stack_trimming) -> true; - (no_binaries) -> true; (debug_info) -> true; (_) -> false end, Opts). |