mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
Emit an error when seeing an invalid condition code in a macro (nasm mode) (#316)
make-check: check .errwarn file first if yasm failed
This commit is contained in:
parent
3ec3aa8c33
commit
8c717107dd
5 changed files with 51 additions and 14 deletions
|
|
@ -3950,8 +3950,7 @@ expand_mmac_params(Token * tline)
|
|||
n = (n + mac->rotate) % mac->nparam;
|
||||
tt = mac->params[n];
|
||||
}
|
||||
cc = find_cc(tt);
|
||||
if (cc == -1)
|
||||
if (!tt)
|
||||
{
|
||||
error(ERR_NONFATAL,
|
||||
"macro parameter %d is not a condition code",
|
||||
|
|
@ -3960,18 +3959,29 @@ expand_mmac_params(Token * tline)
|
|||
}
|
||||
else
|
||||
{
|
||||
type = TOK_ID;
|
||||
if (inverse_ccs[cc] == -1)
|
||||
cc = find_cc(tt);
|
||||
if (cc == -1)
|
||||
{
|
||||
error(ERR_NONFATAL,
|
||||
"condition code `%s' is not invertible",
|
||||
conditions[cc]);
|
||||
"macro parameter %d is not a condition code",
|
||||
n + 1);
|
||||
text = NULL;
|
||||
}
|
||||
else
|
||||
text =
|
||||
nasm_strdup(conditions[inverse_ccs
|
||||
[cc]]);
|
||||
{
|
||||
type = TOK_ID;
|
||||
if (inverse_ccs[cc] == -1)
|
||||
{
|
||||
error(ERR_NONFATAL,
|
||||
"condition code `%s' is not invertible",
|
||||
conditions[cc]);
|
||||
text = NULL;
|
||||
}
|
||||
else
|
||||
text =
|
||||
nasm_strdup(conditions[inverse_ccs
|
||||
[cc]]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '+':
|
||||
|
|
@ -3984,8 +3994,7 @@ expand_mmac_params(Token * tline)
|
|||
n = (n + mac->rotate) % mac->nparam;
|
||||
tt = mac->params[n];
|
||||
}
|
||||
cc = find_cc(tt);
|
||||
if (cc == -1)
|
||||
if (!tt)
|
||||
{
|
||||
error(ERR_NONFATAL,
|
||||
"macro parameter %d is not a condition code",
|
||||
|
|
@ -3994,8 +4003,19 @@ expand_mmac_params(Token * tline)
|
|||
}
|
||||
else
|
||||
{
|
||||
type = TOK_ID;
|
||||
text = nasm_strdup(conditions[cc]);
|
||||
cc = find_cc(tt);
|
||||
if (cc == -1)
|
||||
{
|
||||
error(ERR_NONFATAL,
|
||||
"macro parameter %d is not a condition code",
|
||||
n + 1);
|
||||
text = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = TOK_ID;
|
||||
text = nasm_strdup(conditions[cc]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-bigint.asm
|
|||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-bigint.hex
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-decimal.asm
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-decimal.hex
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-invalidcc.asm
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-invalidcc.errwarn
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-nested.asm
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-nested.errwarn
|
||||
EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-nested.hex
|
||||
|
|
|
|||
9
modules/preprocs/nasm/tests/nasmpp-invalidcc.asm
Normal file
9
modules/preprocs/nasm/tests/nasmpp-invalidcc.asm
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
%macro ret_if_cc 1-*
|
||||
j%+2 %%skip
|
||||
ret
|
||||
j%-2 %%skip
|
||||
ret
|
||||
%%skip:
|
||||
%endmacro
|
||||
|
||||
ret_if_cc ne
|
||||
4
modules/preprocs/nasm/tests/nasmpp-invalidcc.errwarn
Normal file
4
modules/preprocs/nasm/tests/nasmpp-invalidcc.errwarn
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-:9: error: (ret_if_cc:1) macro parameter 2 is not a condition code
|
||||
-:9: error: instruction expected after label
|
||||
-:9: error: (ret_if_cc:3) macro parameter 2 is not a condition code
|
||||
-:9: error: instruction expected after label
|
||||
|
|
@ -28,8 +28,10 @@ do
|
|||
og=`echo ${asm} | sed 's,.asm$,.hex,'`
|
||||
e=${a}.ew
|
||||
eg=`echo ${asm} | sed 's,.asm$,.errwarn,'`
|
||||
egp=1
|
||||
if test \! -f ${eg}; then
|
||||
eg=/dev/null
|
||||
egp=0
|
||||
fi
|
||||
|
||||
# Run within a subshell to prevent signal messages from displaying.
|
||||
|
|
@ -42,7 +44,7 @@ do
|
|||
failedct=`expr $failedct + 1`
|
||||
elif test $status -gt 0; then
|
||||
echo ${asm} | grep err >/dev/null
|
||||
if test $? -gt 0; then
|
||||
if test \( $? -gt 0 \) -a \( \! $egp \); then
|
||||
# YASM detected errors but shouldn't have!
|
||||
echo $ECHO_N "E$ECHO_C"
|
||||
eval "failed$failedct='E: ${a} returned an error code!'"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue