From: Stefan Behnel Date: Wed, 1 May 2013 11:20:14 +0000 (+0200) Subject: suppress warnings about unused error status variables in functions X-Git-Tag: 0.19.1~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bc9ddec230c555dd1e518dc04678ad02d58b87c;p=platform%2Fupstream%2Fpython-cython.git suppress warnings about unused error status variables in functions --- diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 6f144f5..2bfa0b9 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -501,6 +501,7 @@ class FunctionState(object): # However, exceptions may need to be propagated through 'nogil' # sections, in which case we introduce a race condition. self.should_declare_error_indicator = False + self.uses_error_indicator = False # labels @@ -1625,10 +1626,14 @@ class CCodeWriter(object): self.putln("%s%s;" % (static and "static " or "", decl)) if func_context.should_declare_error_indicator: + if self.funcstate.uses_error_indicator: + unused = '' + else: + unused = 'CYTHON_UNUSED ' # Initialize these variables to silence compiler warnings - self.putln("int %s = 0;" % Naming.lineno_cname) - self.putln("const char *%s = NULL;" % Naming.filename_cname) - self.putln("int %s = 0;" % Naming.clineno_cname) + self.putln("%sint %s = 0;" % (unused, Naming.lineno_cname)) + self.putln("%sconst char *%s = NULL;" % (unused, Naming.filename_cname)) + self.putln("%sint %s = 0;" % (unused, Naming.clineno_cname)) def put_h_guard(self, guard): self.putln("#ifndef %s" % guard) @@ -1975,6 +1980,7 @@ class CCodeWriter(object): Naming.lineno_cname, Naming.filename_cname, ) + self.funcstate.uses_error_indicator = True self.putln('__Pyx_AddTraceback("%s", %s, %s, %s);' % format_tuple) def put_trace_declarations(self):