From 3e8b807851337de5abf668892da2a589b6d8fad2 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 3 Dec 2011 10:22:18 +0000 Subject: Give the context in the warning for undefined functions --- pp2cc.py | 13 ++++++++----- 1 file 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))) -- cgit v1.2.1