diff options
Diffstat (limited to 'lib/compiler/test/beam_jump_SUITE.erl')
-rw-r--r-- | lib/compiler/test/beam_jump_SUITE.erl | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/lib/compiler/test/beam_jump_SUITE.erl b/lib/compiler/test/beam_jump_SUITE.erl index b199c175b3..f90eec9446 100644 --- a/lib/compiler/test/beam_jump_SUITE.erl +++ b/lib/compiler/test/beam_jump_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2016-2021. All Rights Reserved. +%% Copyright Ericsson AB 2016-2022. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -169,7 +169,7 @@ expects_h(7, Atom) -> ok. %% When compiled with +no_copt, beam_validator would complain about -%% ambigous try/catch state. +%% ambiguous try/catch state. ambiguous_catch_try_state_1(<<42:false>>) -> %% The beam_ssa_bsm pass will duplicate the entire second clause. %% beam_jump will share the blocks with the build_stacktrace @@ -232,7 +232,8 @@ ambiguous_catch_try_state_3() -> -record(message3, {id, p1, p2}). build_tuple(_Config) -> - {'EXIT',{{badrecord,message3},_}} = (catch do_build_tuple(#message2{})), + Message2 = #message2{}, + {'EXIT',{{badrecord,Message2},_}} = (catch do_build_tuple(#message2{})), ok. do_build_tuple(Message) -> @@ -319,7 +320,15 @@ cs_2(I) -> I. undecided_allocation(_Config) -> ok = catch undecided_allocation_1(<<10:(3*7)>>), - {'EXIT',{{badrecord,rec},_}} = catch undecided_allocation_1(8), + {'EXIT',{{badrecord,<<0>>},_}} = catch undecided_allocation_1(8), + + {bar,1} = undecided_allocation_2(id(<<"bar">>)), + {foo,2} = undecided_allocation_2(id(<<"foo">>)), + {'EXIT',_} = catch undecided_allocation_2(id(<<"foobar">>)), + {'EXIT',{{badmatch,error},_}} = catch undecided_allocation_2(id("foo,bar")), + {'EXIT',_} = catch undecided_allocation_2(id(foobar)), + {'EXIT',_} = catch undecided_allocation_2(id(make_ref())), + ok. -record(rec, {}). @@ -340,6 +349,38 @@ undecided_allocation_1(V) -> >>#rec{}, if whatever -> [] end. +undecided_allocation_2(Order) -> + {_, _} = + case Order of + <<"bar">> -> + {bar, 1}; + <<"foo">> -> + {foo, 2}; + S -> + case string:split("foo", "o") of + [] -> + ok; + _ -> + %% The beam_ssa_bsm pass will duplicate this code, + %% and beam_jump would undo the duplication by sharing + %% the code that calls lists:flatten/1. The problem was + %% that the stack frames had different sizes for the + %% two calls to lists:flatten/1. The diagnostic would be: + %% + %% Internal consistency check failed - please report this bug. + %% Instruction: {call_ext,1,{extfunc,lists,flatten,1}} + %% Error: {allocated,undecided}: + + lists:flatten( + case S of + Y when is_binary(Y) -> Y; + Y -> string:split(Y, ",") + end + ) + end, + error + end. + id(I) -> I. |