From 96773ebcef2fe5949695a4fd923343ec4b049087 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 15 Dec 2009 16:56:13 +0100 Subject: Add option -Werror in erlc(1) Like in gcc, this option treats warnings as errors. --- erts/doc/src/erlc.xml | 4 ++++ erts/etc/common/erlc.c | 3 +++ erts/test/erlc_SUITE.erl | 7 +++++++ 3 files changed, 14 insertions(+) (limited to 'erts') diff --git a/erts/doc/src/erlc.xml b/erts/doc/src/erlc.xml index 3859ac8365..395daa87e7 100644 --- a/erts/doc/src/erlc.xml +++ b/erts/doc/src/erlc.xml @@ -104,6 +104,10 @@ must be quoted. Terms which contain spaces must be quoted on all platforms.

+ -Werror + +

Makes all warnings into errors.

+
-Wnumber

Sets warning level to number. Default is . diff --git a/erts/etc/common/erlc.c b/erts/etc/common/erlc.c index c958fed741..216ff7f40e 100644 --- a/erts/etc/common/erlc.c +++ b/erts/etc/common/erlc.c @@ -310,6 +310,8 @@ main(int argc, char** argv) case 'W': /* Enable warnings. */ if (strcmp(argv[1]+2, "all") == 0) { PUSH2("@warn", "999"); + } else if (strcmp(argv[1]+2, "error") == 0) { + PUSH2("@option", "warnings_as_errors"); } else if (isdigit((int)argv[1][2])) { PUSH2("@warn", argv[1]+2); } else { @@ -566,6 +568,7 @@ usage(void) {"-pz path", "add path to the end of Erlang's code path"}, {"-smp", "compile using SMP emulator"}, {"-v", "verbose compiler output"}, + {"-Werror", "make all warnings into errors"}, {"-W0", "disable warnings"}, {"-Wnumber", "set warning level to number"}, {"-Wall", "enable all warnings"}, diff --git a/erts/test/erlc_SUITE.erl b/erts/test/erlc_SUITE.erl index 1d944811aa..c91471e412 100644 --- a/erts/test/erlc_SUITE.erl +++ b/erts/test/erlc_SUITE.erl @@ -56,6 +56,13 @@ compile_erl(Config) when is_list(Config) -> ?line run(Config, Cmd, FileName, "-W0", ["_OK_"]), + %% Try treating warnings as errors. + + ?line run(Config, Cmd, FileName, "-Werror", + ["compile: warnings being treated as errors\$", + "Warning: function foo/0 is unused\$", + "_ERROR_"]), + %% Check a bad file. ?line BadFile = filename:join(SrcDir, "erl_test_bad.erl"), -- cgit v1.2.3