aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-11-16 07:26:07 +0100
committerBjörn Gustavsson <[email protected]>2012-12-06 14:22:36 +0100
commit81d6790acf9d55a63575efd93bdba1629c101b62 (patch)
tree319b38eda076912823460c2e4302d7e9f9756e93 /lib
parentca3b66e3d2c734e8715c7ed078e4fa9ae10462de (diff)
downloadotp-81d6790acf9d55a63575efd93bdba1629c101b62.tar.gz
otp-81d6790acf9d55a63575efd93bdba1629c101b62.tar.bz2
otp-81d6790acf9d55a63575efd93bdba1629c101b62.zip
Suppress warnings for unused variables using a compiler option
Currently, the generated code suppresses warnings for unusued variables by assigning to the "_Val" variable, for example: _Val = Tmpval5 To be completely safe, that should have been: _ = Tmpval5 in case there happens to more than one such assignment in the same scope. However, a better way to suppress warnings is to simply use the 'nowarn_unused_vars' compiler option. That method will also work for more complicated expressions there it would be cumbersome to suppress warnings by assignment to "_".
Diffstat (limited to 'lib')
-rw-r--r--lib/asn1/src/asn1ct_constructed_per.erl4
-rw-r--r--lib/asn1/src/asn1ct_gen.erl2
2 files changed, 2 insertions, 4 deletions
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl
index e4e0e064e8..46034622c8 100644
--- a/lib/asn1/src/asn1ct_constructed_per.erl
+++ b/lib/asn1/src/asn1ct_constructed_per.erl
@@ -76,9 +76,7 @@ gen_encode_constructed(Erule,Typename,D) when is_record(D,type) ->
case {Optionals = optionals(to_textual_order(CompList)),CompList,
is_optimized(Erule)} of
{[],EmptyCL,_} when EmptyCL == {[],[],[]};EmptyCL == {[],[]};EmptyCL == [] ->
- emit(["%%Variable setting just to eliminate ",
- "compiler warning for unused vars!",nl,
- "_Val = ",{curr,val},",",nl]);
+ ok;
{[],_,_} ->
emit([{next,val}," = ",{curr,val},",",nl]);
{_,_,true} ->
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index b0990e92cf..57b12ce186 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -1405,7 +1405,7 @@ gen_head(Erules,Mod,Hrl) ->
emit({"%% Purpose: encoder and decoder to the types in mod ",Mod,nl,nl}),
emit({"-module('",Mod,"').",nl}),
put(currmod,Mod),
- %emit({"-compile(export_all).",nl}),
+ emit({"-compile(nowarn_unused_vars).",nl}),
case {Hrl,lists:member(inline,get(encoding_options))} of
{0,_} -> true;
{_,true} -> true;