aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-02-09 10:31:04 +0100
committerBjörn Gustavsson <[email protected]>2011-02-09 10:31:04 +0100
commit7b7409702272dd26ce248d5642c6840d07752183 (patch)
tree5291b0d88e876e1b2f3c47e1d01c7e949df5c6c5
parente3d12b73ffcbc85d276414128482d7946bd0b861 (diff)
parent9e2aa4739c22ae5af6e1d8c4fed19a979beadf8c (diff)
downloadotp-7b7409702272dd26ce248d5642c6840d07752183.tar.gz
otp-7b7409702272dd26ce248d5642c6840d07752183.tar.bz2
otp-7b7409702272dd26ce248d5642c6840d07752183.zip
Merge branch 'bjorn/compiler/eliminate-warnings' into dev
* bjorn/compiler/eliminate-warnings: compiler Makefile: Turn warnings into errors v3_kernel_pp: Add support for pretty-printing #k_literal{} records v3_kernel_pp: Eliminate warning
-rw-r--r--lib/compiler/src/Makefile4
-rw-r--r--lib/compiler/src/v3_kernel_pp.erl48
2 files changed, 31 insertions, 21 deletions
diff --git a/lib/compiler/src/Makefile b/lib/compiler/src/Makefile
index 0f6d2f6193..9da9253f5b 100644
--- a/lib/compiler/src/Makefile
+++ b/lib/compiler/src/Makefile
@@ -118,7 +118,9 @@ APPUP_TARGET= $(EBIN)/$(APPUP_FILE)
ifeq ($(NATIVE_LIBS_ENABLED),yes)
ERL_COMPILE_FLAGS += +native
endif
-ERL_COMPILE_FLAGS += +inline +warn_unused_import -I../../stdlib/include -I$(EGEN) -W
+ERL_COMPILE_FLAGS += +inline +warn_unused_import \
+ +warnings_as_errors \
+ -I../../stdlib/include -I$(EGEN) -W
# ----------------------------------------------------
# Targets
diff --git a/lib/compiler/src/v3_kernel_pp.erl b/lib/compiler/src/v3_kernel_pp.erl
index a300dd283f..9bd13f7032 100644
--- a/lib/compiler/src/v3_kernel_pp.erl
+++ b/lib/compiler/src/v3_kernel_pp.erl
@@ -50,28 +50,34 @@ format(Node) -> format(Node, #ctxt{}).
format(Node, Ctxt) ->
case canno(Node) of
-%% [] ->
-%% format_1(Node, Ctxt);
-%% [L,{file,_}] when is_integer(L) ->
-%% format_1(Node, Ctxt);
-%% #k{a=Anno}=K when Anno =/= [] ->
-%% format(setelement(2, Node, K#k{a=[]}), Ctxt);
-%% List ->
-%% format_anno(List, Ctxt, fun (Ctxt1) ->
-%% format_1(Node, Ctxt1)
-%% end);
- _ ->
- format_1(Node, Ctxt)
+ [] ->
+ format_1(Node, Ctxt);
+ [L,{file,_}] when is_integer(L) ->
+ format_1(Node, Ctxt);
+ #k{a=Anno}=K when Anno =/= [] ->
+ format(setelement(2, Node, K#k{a=[]}), Ctxt);
+ List ->
+ format_anno(List, Ctxt, fun (Ctxt1) ->
+ format_1(Node, Ctxt1)
+ end)
end.
-%% format_anno(Anno, Ctxt0, ObjFun) ->
-%% Ctxt1 = ctxt_bump_indent(Ctxt0, 1),
-%% ["( ",
-%% ObjFun(Ctxt0),
-%% nl_indent(Ctxt1),
-%% "-| ",io_lib:write(Anno),
-%% " )"].
-
+format_anno(Anno, Ctxt0, ObjFun) ->
+ case annotations_enabled() of
+ true ->
+ Ctxt1 = ctxt_bump_indent(Ctxt0, 1),
+ ["( ",
+ ObjFun(Ctxt0),
+ nl_indent(Ctxt1),
+ "-| ",io_lib:write(Anno),
+ " )"];
+ false ->
+ ObjFun(Ctxt0)
+ end.
+
+%% By default, don't show annotations since they clutter up the output.
+annotations_enabled() ->
+ false.
%% format_1(Kexpr, Context) -> string().
@@ -107,6 +113,8 @@ format_1(#k_bin_int{size=Sz,unit=U,flags=Fs,val=Val,next=Next}, Ctxt) ->
[format_bin_seg_1(S, Ctxt),
format_bin_seg(Next, ctxt_bump_indent(Ctxt, 2))];
format_1(#k_bin_end{}, _Ctxt) -> "#<>#";
+format_1(#k_literal{val=Term}, _Ctxt) ->
+ io_lib:format("~p", [Term]);
format_1(#k_local{name=N,arity=A}, Ctxt) ->
"local " ++ format_fa_pair({N,A}, Ctxt);
format_1(#k_remote{mod=M,name=N,arity=A}, _Ctxt) ->