aboutsummaryrefslogtreecommitdiffstats
path: root/lib/parsetools/src/yecc.erl
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2011-09-13 12:15:25 +0200
committerHenrik Nord <[email protected]>2011-09-13 12:15:25 +0200
commitae7e9b6d23c63bf73d9e22ea0b21b79b51900655 (patch)
tree014a38031436168347d42d9fe906a5abda114fd7 /lib/parsetools/src/yecc.erl
parent7b5a8a65d1f4e8070fd1d771a79b7b5237100c63 (diff)
parente9e118a25ee822e4568d785844d249e083cd88cf (diff)
downloadotp-ae7e9b6d23c63bf73d9e22ea0b21b79b51900655.tar.gz
otp-ae7e9b6d23c63bf73d9e22ea0b21b79b51900655.tar.bz2
otp-ae7e9b6d23c63bf73d9e22ea0b21b79b51900655.zip
Merge branch 'dev' into major
Conflicts: lib/asn1/doc/src/asn1ct.xml
Diffstat (limited to 'lib/parsetools/src/yecc.erl')
-rw-r--r--lib/parsetools/src/yecc.erl37
1 files changed, 24 insertions, 13 deletions
diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl
index 72cff3af92..354d56527d 100644
--- a/lib/parsetools/src/yecc.erl
+++ b/lib/parsetools/src/yecc.erl
@@ -133,12 +133,15 @@
%%% Interface to erl_compile.
compile(Input0, Output0,
- #options{warning = WarnLevel, verbose=Verbose, includes=Includes}) ->
+ #options{warning = WarnLevel, verbose=Verbose, includes=Includes,
+ specific=Specific}) ->
Input = shorten_filename(Input0),
Output = shorten_filename(Output0),
Includefile = lists:sublist(Includes, 1),
+ Werror = proplists:get_bool(warnings_as_errors, Specific),
Opts = [{parserfile,Output}, {includefile,Includefile}, {verbose,Verbose},
- {report_errors, true}, {report_warnings, WarnLevel > 0}],
+ {report_errors, true}, {report_warnings, WarnLevel > 0},
+ {warnings_as_errors, Werror}],
case file(Input, Opts) of
{ok, _OutFile} ->
ok;
@@ -411,15 +414,15 @@ infile(Parent, Infilex, Options) ->
{error, Reason} ->
add_error(St0#yecc.infile, none, {file_error, Reason}, St0)
end,
- case {St#yecc.errors, werr(St)} of
+ case {St#yecc.errors, werror(St)} of
{[], false} -> ok;
_ -> _ = file:delete(St#yecc.outfile)
end,
Parent ! {self(), yecc_ret(St)}.
-werr(St) ->
- member(warnings_as_errors, St#yecc.options)
- andalso length(St#yecc.warnings) > 0.
+werror(St) ->
+ St#yecc.warnings =/= []
+ andalso member(warnings_as_errors, St#yecc.options).
outfile(St0) ->
case file:open(St0#yecc.outfile, [write, delayed_write]) of
@@ -783,9 +786,9 @@ yecc_ret(St0) ->
report_warnings(St),
Es = pack_errors(St#yecc.errors),
Ws = pack_warnings(St#yecc.warnings),
- Werr = werr(St),
+ Werror = werror(St),
if
- Werr ->
+ Werror ->
do_error_return(St, Es, Ws);
Es =:= [] ->
case member(return_warnings, St#yecc.options) of
@@ -849,14 +852,22 @@ report_errors(St) ->
end.
report_warnings(St) ->
- case member(report_warnings, St#yecc.options) of
+ Werror = member(warnings_as_errors, St#yecc.options),
+ Prefix = case Werror of
+ true -> "";
+ false -> "Warning: "
+ end,
+ ReportWerror = Werror andalso member(report_errors, St#yecc.options),
+ case member(report_warnings, St#yecc.options) orelse ReportWerror of
true ->
foreach(fun({File,{none,Mod,W}}) ->
- io:fwrite(<<"~s: Warning: ~s\n">>,
- [File,Mod:format_error(W)]);
+ io:fwrite(<<"~s: ~s~s\n">>,
+ [File,Prefix,
+ Mod:format_error(W)]);
({File,{Line,Mod,W}}) ->
- io:fwrite(<<"~s:~w: Warning: ~s\n">>,
- [File,Line,Mod:format_error(W)])
+ io:fwrite(<<"~s:~w: ~s~s\n">>,
+ [File,Line,Prefix,
+ Mod:format_error(W)])
end, sort(St#yecc.warnings));
false ->
ok