summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2011-12-03 10:22:18 +0000
committerPeter Wu <lekensteyn@gmail.com>2011-12-03 10:22:18 +0000
commit3e8b807851337de5abf668892da2a589b6d8fad2 (patch)
treee4579bee5247b18e17b1adaf7035e2fd6f9f3f30
parent30fc12c61857d9f242953e49b97118c976170d13 (diff)
downloadpp2cc-3e8b807851337de5abf668892da2a589b6d8fad2.tar.gz
Give the context in the warning for undefined functions
-rwxr-xr-xpp2cc.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/pp2cc.py b/pp2cc.py
index 9de64dd..4c83afb 100755
--- a/pp2cc.py
+++ b/pp2cc.py
@@ -243,10 +243,7 @@ class Parse(object):
if name in self.functions:
function = self.functions[name]
return function.labelBegin()
- # name not found :? perhaps an external declaration
- lbl = "fn_" + name
- self.logger.warning("call to undefined function, assuming label '{}'".format(lbl))
- return lbl
+ return None
def parseCompound(self, linked_node):
linked_node.incrementLevel()
@@ -749,7 +746,13 @@ class Parse(object):
lines += line
lines.append(self.asm.push(result_reg))
- lines.append(self.asm.branch_op("BRS", self.functionLabel(funcname)))
+ lbl_func = self.functionLabel(funcname)
+ if lbl_func is None:
+ # name not found :? perhaps an external declaration
+ lbl = "fn_" + funcname
+ self.logger.warning("call to undefined function, assuming label"
+ " '{}'".format(lbl), linked_node=linked_node)
+ lines.append(self.asm.branch_op("BRS", lbl_func))
if params:
lines.append(self.asm.binary_op("ADD", "SP", len(params.exprs)))