mirror of https://github.com/xemu-project/xemu.git
decodetree: Properly diagnose fields overflowing an insn
Previously this would result in an exception for shifting the field mask by a negative number. Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
71ecf79bf4
commit
2decfc9558
|
@ -622,6 +622,8 @@ def parse_generic(lineno, is_format, name, toks):
|
||||||
sign = True
|
sign = True
|
||||||
flen = flen[1:]
|
flen = flen[1:]
|
||||||
shift = int(flen, 10)
|
shift = int(flen, 10)
|
||||||
|
if shift + width > insnwidth:
|
||||||
|
error(lineno, 'field {0} exceeds insnwidth'.format(fname))
|
||||||
f = Field(sign, insnwidth - width - shift, shift)
|
f = Field(sign, insnwidth - width - shift, shift)
|
||||||
flds = add_field(lineno, flds, fname, f)
|
flds = add_field(lineno, flds, fname, f)
|
||||||
fixedbits <<= shift
|
fixedbits <<= shift
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
||||||
|
# See the COPYING.LIB file in the top-level directory.
|
||||||
|
|
||||||
|
# Diagnose too many bits (33 of 32)
|
||||||
|
one 000000000000000000000000000000000
|
|
@ -0,0 +1,5 @@
|
||||||
|
# This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
||||||
|
# See the COPYING.LIB file in the top-level directory.
|
||||||
|
|
||||||
|
# Diagnose too few bits (31 of 32)
|
||||||
|
one 0000000000000000000000000000000
|
|
@ -0,0 +1,5 @@
|
||||||
|
# This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
||||||
|
# See the COPYING.LIB file in the top-level directory.
|
||||||
|
|
||||||
|
# Diagnose too many bits (33 of 32)
|
||||||
|
one 0 s:32
|
|
@ -0,0 +1,5 @@
|
||||||
|
# This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
||||||
|
# See the COPYING.LIB file in the top-level directory.
|
||||||
|
|
||||||
|
# Diagnose too few bits (31 of 32)
|
||||||
|
one 0 s:30
|
Loading…
Reference in New Issue