Skip to content

Commit 259c06c

Browse files
committed
Fix wrong filename on not called functions
If the function were declared in another (included file) the origina name was not shown, but the main one. Fixed.
1 parent 5216d06 commit 259c06c

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

api/optimize.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def visit_CALL(self, node):
140140

141141
def visit_FUNCDECL(self, node):
142142
if self.O_LEVEL > 1 and not node.entry.accessed:
143-
warning(node.entry.lineno, "Function '%s' is never called and has been ignored" % node.entry.name)
143+
warning(node.entry.lineno, "Function '%s' is never called and has been ignored" % node.entry.name,
144+
fname=node.entry.filename)
144145
yield self.NOP
145146
else:
146147
node.children[1] = (yield ToVisit(node.entry))
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
jp __MAIN_PROGRAM__
14+
ZXBASIC_USER_DATA:
15+
; Defines USER DATA Length in bytes
16+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
17+
.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN
18+
.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA
19+
ZXBASIC_USER_DATA_END:
20+
__MAIN_PROGRAM__:
21+
ld hl, 0
22+
ld b, h
23+
ld c, l
24+
__END_PROGRAM:
25+
di
26+
ld hl, (__CALL_BACK__)
27+
ld sp, hl
28+
exx
29+
pop hl
30+
pop iy
31+
pop ix
32+
exx
33+
ei
34+
ret
35+
__CALL_BACK__:
36+
DEFW 0
37+
END
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "func0.bas"
2+

tests/functional/test_errmsg.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,7 @@ dim_at_label7.bas:3: error: Circular dependency between 'a' and 'c'
160160
dim_at_label7.bas:4: error: Circular dependency between 'c' and 'b'
161161
>>> process_file('include_error.bas')
162162
llb.bas:3: error: Undeclared function "f$"
163+
>>> process_file('opt2_include_unused.bas')
164+
func0.bas:5: warning: Using default implicit type 'float' for 'f'
165+
func0.bas:4: warning: Function 'f' is never called and has been ignored
163166

0 commit comments

Comments
 (0)