Skip to content

Commit f6205df

Browse files
committed
Refact FASTCALL warning
This will make the fastcall muteable
1 parent b693c3e commit f6205df

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/api/errmsg.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,26 @@ def warning_empty_loop(lineno: int):
151151

152152

153153
@register_warning('140')
154-
def warning_empty_if(lineno):
154+
def warning_empty_if(lineno: int):
155155
""" Warning: Useless empty IF ignored
156156
"""
157157
warning(lineno, 'Useless empty IF ignored')
158158

159159

160160
@register_warning('150')
161-
def warning_not_used(lineno, id_, kind='Variable'):
161+
def warning_not_used(lineno: int, id_: str, kind: str = 'Variable'):
162162
""" Emits an optimization warning
163163
"""
164164
if OPTIONS.optimization > 0:
165165
warning(lineno, "%s '%s' is never used" % (kind, id_))
166166

167+
168+
@register_warning('160')
169+
def warning_fastcall_with_N_parameters(lineno: int, kind: str, id_: str, num_params: int):
170+
""" Warning: SUB/FUNCTION declared as FASTCALL with N parameters
171+
"""
172+
warning(lineno, f"{kind} '{id_}' declared as FASTCALL with {num_params} parameters")
173+
167174
# endregion
168175

169176
# region [Syntax Errors]

src/libzxbc/zxbparser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,8 +2974,7 @@ def p_function_header_pre(p):
29742974

29752975
if p[0].entry.convention == CONVENTION.fastcall and len(p[2]) > 1:
29762976
kind = 'SUB' if FUNCTION_LEVEL[-1].kind == KIND.sub else 'FUNCTION'
2977-
warning(lineno, "%s '%s' declared as FASTCALL with %i parameters" % (kind, p[0].entry.name,
2978-
len(p[2])))
2977+
src.api.errmsg.warning_fastcall_with_N_parameters(lineno, kind, p[0].entry.name, len(p[2]))
29792978

29802979

29812980
def p_function_error(p):

0 commit comments

Comments
 (0)