Add command line flag --warning-errors and gcc compat alias -Werror
authorVitja Makarov <vitja.makarov@gmail.com>
Sat, 29 Jan 2011 06:49:18 +0000 (09:49 +0300)
committerVitja Makarov <vitja.makarov@gmail.com>
Thu, 14 Apr 2011 09:07:14 +0000 (13:07 +0400)
Cython/Compiler/CmdLine.py
Cython/Compiler/Errors.py
Cython/Compiler/Options.py

index 60eff8dbd4e026108c89f1fff557ec7e653ba10b..327d38b78b62456c78f9c1d2b0623e441fa0cdbb 100644 (file)
@@ -38,6 +38,7 @@ Options:
   -2                             Compile based on Python-2 syntax and code semantics.
   -3                             Compile based on Python-3 syntax and code semantics.
   --fast-fail                    Abort the compilation on the first error
+  --warning-error, -Werror       Make all warnings into errors
   -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
 """
 
@@ -131,6 +132,8 @@ def parse_command_line(args):
                 options.language_level = 3
             elif option == "--fast-fail":
                 Options.fast_fail = True
+            elif option in ('-Werror', '--warning-errors'):
+                Options.warning_errors = True
             elif option == "--disable-function-redefinition":
                 Options.disable_function_redefinition = True
             elif option in ("-X", "--directive"):
index fc59dfc98de8ddd709639302f2ba4f251256ebd2..c50f0230893593370a5df6ad0734babe1d9ce3f7 100644 (file)
@@ -176,6 +176,8 @@ def message(position, message, level=1):
 def warning(position, message, level=0):
     if level < LEVEL:
         return
+    if Options.warning_errors:
+        return error(position, message)
     warn = CompileWarning(position, message)
     line = "warning: %s\n" % warn
     if listing_file:
index 35a7e7ee151642e326165378da53376fb3b4faec..2e3663aebbf84ad44cbdfcab646b8e2f36d6b48c 100644 (file)
@@ -22,6 +22,9 @@ annotate = False
 # to keep going and printing further error messages.
 fast_fail = False
 
+# Make all warnings into errors.
+warning_errors = False
+
 # This will convert statements of the form "for i in range(...)"
 # to "for i from ..." when i is a cdef'd integer type, and the direction
 # (i.e. sign of step) can be determined.