aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-03-19 16:26:28 +0100
committerBjörn Gustavsson <[email protected]>2015-03-19 16:26:28 +0100
commit8bccd7b8bf4e785c41d20f2010601c4f5a2db76a (patch)
tree2aee3731d0997d9052041754cf7eb1ec89e21322
parent65c7116bb38013c3d829f21b00bf094606e46731 (diff)
parent9e07ede3f954bdfc6af9f82c1b8261e38b8d857c (diff)
downloadotp-8bccd7b8bf4e785c41d20f2010601c4f5a2db76a.tar.gz
otp-8bccd7b8bf4e785c41d20f2010601c4f5a2db76a.tar.bz2
otp-8bccd7b8bf4e785c41d20f2010601c4f5a2db76a.zip
Merge branch 'bjorn/asn1/eliminate-warning'
* bjorn/asn1/eliminate-warning: PER, UPER: Eliminate compiler warning for SeqPrim.asn1
-rw-r--r--lib/asn1/src/asn1ct_imm.erl33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/asn1/src/asn1ct_imm.erl b/lib/asn1/src/asn1ct_imm.erl
index 91820e08de..5bf69e9294 100644
--- a/lib/asn1/src/asn1ct_imm.erl
+++ b/lib/asn1/src/asn1ct_imm.erl
@@ -1922,16 +1922,7 @@ enc_opt(nil, St) ->
enc_opt({seq,H0,T0}, St0) ->
{H,St1} = enc_opt(H0, St0),
{T,St} = enc_opt(T0, St1),
- case {H,T} of
- {none,_} ->
- {T,St};
- {{list,Imm,Data},
- {seq,{call,per,complete,[Data],_},_}} ->
- %% Get rid of any explicit 'align' added by per_enc_open_type/2.
- {{seq,{list,remove_trailing_align(Imm),Data},T},St};
- {_,_} ->
- {{seq,H,T},St}
- end;
+ {enc_opt_seq(H, T),St};
enc_opt({set,_,_}=Imm, St) ->
{Imm,St#ost{t=undefined}};
enc_opt({sub,Src0,Int,Dst}, St0) ->
@@ -1965,6 +1956,28 @@ remove_trailing_align({seq,H,T}) ->
{seq,H,remove_trailing_align(T)};
remove_trailing_align(Imm) -> Imm.
+enc_opt_seq(none, T) ->
+ T;
+enc_opt_seq({list,Imm,Data}, {seq,{call,per,complete,[Data],_},_}=T) ->
+ %% Get rid of any explicit 'align' added by per_enc_open_type/2.
+ {seq,{list,remove_trailing_align(Imm),Data},T};
+enc_opt_seq({call,_,_,_,{var,_}=Dst}=H, T) ->
+ case is_var_unused(Dst, T) of
+ false -> {seq,H,T};
+ true -> T
+ end;
+enc_opt_seq(H, T) ->
+ {seq,H,T}.
+
+is_var_unused(_, align) ->
+ true;
+is_var_unused(V, {call,_,_,Args}) ->
+ not lists:member(V, Args);
+is_var_unused(V, {cons,H,T}) ->
+ is_var_unused(V, H) andalso is_var_unused(V, T);
+is_var_unused(_, _) ->
+ false.
+
bit_size_propagate(Bin, Type, St) ->
case t_range(Type) of
any ->