Commit 0b657721 authored by Stefan Behnel's avatar Stefan Behnel

prevent unused '_' variables from appearing in C code

parent 6e4ccc8e
...@@ -615,17 +615,19 @@ def check_definitions(flow, compiler_directives): ...@@ -615,17 +615,19 @@ def check_definitions(flow, compiler_directives):
# Unused entries # Unused entries
for entry in flow.entries: for entry in flow.entries:
if (not entry.cf_references and not entry.is_pyclass_attr if (not entry.cf_references
and not entry.in_closure and not entry.is_pyclass_attr
and entry.name != '_'): and not entry.in_closure):
if entry.is_arg: if entry.name != '_':
if warn_unused_arg: # '_' is often used for unused variables, e.g. in loops
messages.warning(entry.pos, "Unused argument '%s'" % if entry.is_arg:
entry.name) if warn_unused_arg:
else: messages.warning(entry.pos, "Unused argument '%s'" %
if warn_unused: entry.name)
messages.warning(entry.pos, "Unused entry '%s'" % else:
entry.name) if warn_unused:
messages.warning(entry.pos, "Unused entry '%s'" %
entry.name)
entry.cf_used = False entry.cf_used = False
messages.report() messages.report()
......
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