Commit 03397f1d authored by Ondrej Certik's avatar Ondrej Certik

Implement the --fatal-errors command line option

If enabled, it will abort on the first error occured. Just like "gcc
-Wfatal-errors".
Signed-off-by: default avatarOndrej Certik <ondrej@certik.cz>
parent 16055821
...@@ -35,6 +35,7 @@ Options: ...@@ -35,6 +35,7 @@ Options:
--embed Embed the Python interpreter in a main() method. --embed Embed the Python interpreter in a main() method.
-2 Compile based on Python-2 syntax and code semantics. -2 Compile based on Python-2 syntax and code semantics.
-3 Compile based on Python-3 syntax and code semantics. -3 Compile based on Python-3 syntax and code semantics.
--fatal-errors Abort the compilation on the first error
-X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
""" """
...@@ -117,6 +118,8 @@ def parse_command_line(args): ...@@ -117,6 +118,8 @@ def parse_command_line(args):
options.language_level = 2 options.language_level = 2
elif option == '-3': elif option == '-3':
options.language_level = 3 options.language_level = 3
elif option == "--fatal-errors":
Options.fatal_errors = True
elif option in ("-X", "--directive"): elif option in ("-X", "--directive"):
try: try:
options.compiler_directives = Options.parse_directive_list( options.compiler_directives = Options.parse_directive_list(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import sys import sys
from Cython.Utils import open_new_file from Cython.Utils import open_new_file
from DebugFlags import debug_exception_on_error from DebugFlags import debug_exception_on_error
import Options
class PyrexError(Exception): class PyrexError(Exception):
...@@ -138,6 +139,8 @@ def report_error(err): ...@@ -138,6 +139,8 @@ def report_error(err):
except UnicodeEncodeError: except UnicodeEncodeError:
echo_file.write(line.encode('ASCII', 'replace')) echo_file.write(line.encode('ASCII', 'replace'))
num_errors = num_errors + 1 num_errors = num_errors + 1
if Options.fatal_errors:
sys.exit(1)
def error(position, message): def error(position, message):
#print "Errors.error:", repr(position), repr(message) ### #print "Errors.error:", repr(position), repr(message) ###
......
...@@ -18,6 +18,10 @@ generate_cleanup_code = 0 ...@@ -18,6 +18,10 @@ generate_cleanup_code = 0
annotate = 0 annotate = 0
# This will abort the compilation on the first error occured rather than trying
# to keep going and printing further error messages.
fatal_errors = False
# This will convert statements of the form "for i in range(...)" # 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 # to "for i from ..." when i is a cdef'd integer type, and the direction
# (i.e. sign of step) can be determined. # (i.e. sign of step) can be determined.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment