diff options
author | Björn Gustavsson <[email protected]> | 2017-04-24 10:15:50 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-04-24 10:15:50 +0200 |
commit | e1f468dedf124bd20ac084fcadb15b88e406733f (patch) | |
tree | 00531939bedc48f8a086f16582fa8c3c18086120 | |
parent | 52744948f4bbe85dee428cefdf9d205665a57b18 (diff) | |
parent | c3e1aebf3319eaa4c617560f29bf81a697473d07 (diff) | |
download | otp-e1f468dedf124bd20ac084fcadb15b88e406733f.tar.gz otp-e1f468dedf124bd20ac084fcadb15b88e406733f.tar.bz2 otp-e1f468dedf124bd20ac084fcadb15b88e406733f.zip |
Merge pull request #1419 from michalmuskala/consistency-fix
Make beam_validator track type formation for binary operations
-rw-r--r-- | lib/compiler/src/beam_validator.erl | 16 | ||||
-rw-r--r-- | lib/compiler/test/beam_type_SUITE.erl | 11 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index c26e5719aa..ca60e1b2de 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -623,17 +623,17 @@ valfun_4({test,bs_skip_utf16,{f,Fail},[Ctx,Live,_]}, Vst) -> valfun_4({test,bs_skip_utf32,{f,Fail},[Ctx,Live,_]}, Vst) -> validate_bs_skip_utf(Fail, Ctx, Live, Vst); valfun_4({test,bs_get_integer2,{f,Fail},Live,[Ctx,_,_,_],Dst}, Vst) -> - validate_bs_get(Fail, Ctx, Live, Dst, Vst); + validate_bs_get(Fail, Ctx, Live, {integer, []}, Dst, Vst); valfun_4({test,bs_get_float2,{f,Fail},Live,[Ctx,_,_,_],Dst}, Vst) -> - validate_bs_get(Fail, Ctx, Live, Dst, Vst); + validate_bs_get(Fail, Ctx, Live, {float, []}, Dst, Vst); valfun_4({test,bs_get_binary2,{f,Fail},Live,[Ctx,_,_,_],Dst}, Vst) -> - validate_bs_get(Fail, Ctx, Live, Dst, Vst); + validate_bs_get(Fail, Ctx, Live, term, Dst, Vst); valfun_4({test,bs_get_utf8,{f,Fail},Live,[Ctx,_],Dst}, Vst) -> - validate_bs_get(Fail, Ctx, Live, Dst, Vst); + validate_bs_get(Fail, Ctx, Live, {integer, []}, Dst, Vst); valfun_4({test,bs_get_utf16,{f,Fail},Live,[Ctx,_],Dst}, Vst) -> - validate_bs_get(Fail, Ctx, Live, Dst, Vst); + validate_bs_get(Fail, Ctx, Live, {integer, []}, Dst, Vst); valfun_4({test,bs_get_utf32,{f,Fail},Live,[Ctx,_],Dst}, Vst) -> - validate_bs_get(Fail, Ctx, Live, Dst, Vst); + validate_bs_get(Fail, Ctx, Live, {integer, []}, Dst, Vst); valfun_4({bs_save2,Ctx,SavePoint}, Vst) -> bsm_save(Ctx, SavePoint, Vst); valfun_4({bs_restore2,Ctx,SavePoint}, Vst) -> @@ -794,12 +794,12 @@ verify_put_map(Fail, Src, Dst, Live, List, Vst0) -> %% %% Common code for validating bs_get* instructions. %% -validate_bs_get(Fail, Ctx, Live, Dst, Vst0) -> +validate_bs_get(Fail, Ctx, Live, Type, Dst, Vst0) -> bsm_validate_context(Ctx, Vst0), verify_live(Live, Vst0), Vst1 = prune_x_regs(Live, Vst0), Vst = branch_state(Fail, Vst1), - set_type_reg(term, Dst, Vst). + set_type_reg(Type, Dst, Vst). %% %% Common code for validating bs_skip_utf* instructions. diff --git a/lib/compiler/test/beam_type_SUITE.erl b/lib/compiler/test/beam_type_SUITE.erl index 7ca544a537..c11883d5ff 100644 --- a/lib/compiler/test/beam_type_SUITE.erl +++ b/lib/compiler/test/beam_type_SUITE.erl @@ -22,7 +22,7 @@ -export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1, init_per_group/2,end_per_group/2, integers/1,coverage/1,booleans/1,setelement/1,cons/1, - tuple/1,record_float/1]). + tuple/1,record_float/1,binary_float/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -38,7 +38,8 @@ groups() -> setelement, cons, tuple, - record_float + record_float, + binary_float ]}]. init_per_suite(Config) -> @@ -143,6 +144,12 @@ record_float(R, N0) -> N end. +binary_float(_Config) -> + <<-1/float>> = binary_negate_float(<<1/float>>), + ok. + +binary_negate_float(<<Float/float>>) -> + <<-Float/float>>. id(I) -> I. |