From a6b46d18e04c23cf8f7798ebc4ef34e4e03eb04e Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Tue, 2 Aug 2011 16:41:53 +0200 Subject: yecc: log warnings as errors if -Werror is enabled --- lib/parsetools/src/yecc.erl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/parsetools/src/yecc.erl') diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl index d714420680..d03435c441 100644 --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -852,14 +852,22 @@ report_errors(St) -> end. report_warnings(St) -> - case member(report_warnings, St#yecc.options) of + Werr = member(warnings_as_errors, St#yecc.options), + Prefix = case Werr of + true -> ""; + false -> "Warning: " + end, + ReportWerr = Werr andalso member(report_errors, St#yecc.options), + case member(report_warnings, St#yecc.options) orelse ReportWerr 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 -- cgit v1.2.3