Commit 94e0e9a9 authored by Stefan Behnel's avatar Stefan Behnel

Generate function-local error indicator variables whenever "error_goto()" is used.

This was previously broken by the introduction of the "__PYX_ERR()" macro.
parent b648b65a
......@@ -2344,24 +2344,18 @@ class CCodeWriter(object):
self.funcstate.should_declare_error_indicator = True
if used:
self.funcstate.uses_error_indicator = True
if self.code_config.c_line_in_traceback:
cinfo = " %s = %s;" % (Naming.clineno_cname, Naming.line_c_macro)
else:
cinfo = ""
return "%s = %s[%s]; %s = %s;%s" % (
Naming.filename_cname,
Naming.filetable_cname,
return "__PYX_MARK_ERR_POS(%s, %s)" % (
self.lookup_filename(pos[0]),
Naming.lineno_cname,
pos[1],
cinfo)
pos[1])
def error_goto(self, pos):
def error_goto(self, pos, used=True):
lbl = self.funcstate.error_label
self.funcstate.use_label(lbl)
if pos is None:
return 'goto %s;' % lbl
self.funcstate.should_declare_error_indicator = True
if used:
self.funcstate.uses_error_indicator = True
return "__PYX_ERR(%s, %s, %s)" % (
self.lookup_filename(pos[0]),
pos[1],
......
......@@ -658,16 +658,19 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self._put_setup_code(code, "PythonCompatibility")
self._put_setup_code(code, "MathInitCode")
# Using "(void)cname" to prevent "unused" warnings.
if options.c_line_in_traceback:
cinfo = "%s = %s; " % (Naming.clineno_cname, Naming.line_c_macro)
cinfo = "%s = %s; (void)%s; " % (Naming.clineno_cname, Naming.line_c_macro, Naming.clineno_cname)
else:
cinfo = ""
code.put("""
#define __PYX_ERR(f_index, lineno, Ln_error) \\
{ \\
%s = %s[f_index]; %s = lineno; %sgoto Ln_error; \\
}
""" % (Naming.filename_cname, Naming.filetable_cname, Naming.lineno_cname, cinfo))
code.putln("#define __PYX_MARK_ERR_POS(f_index, lineno) \\")
code.putln(" { %s = %s[f_index]; (void)%s; %s = lineno; (void)%s; %s}" % (
Naming.filename_cname, Naming.filetable_cname, Naming.filename_cname,
Naming.lineno_cname, Naming.lineno_cname,
cinfo
))
code.putln("#define __PYX_ERR(f_index, lineno, Ln_error) \\")
code.putln(" { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }")
code.putln("")
self.generate_extern_c_macro_definition(code)
......
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