Fix non-compliance problem with octal/hex literals without U suffix

To follow the standard, hexadecimal and octal values that don't fit an intmax_t must be of type uintmax_t, regardless of the presence of the U suffix.
This commit is contained in:
Sei Lisa 2019-01-21 16:22:10 +01:00
parent dc41b36ace
commit 326091624c

View file

@ -317,7 +317,10 @@ class Evaluator(object):
raise EvalError("Invalid integer literal")
val = (int(m.group(2), 8) if m.group(2)
else int(m.group(1) or m.group(3), 0))
val = self.to_uint(val) if m.group(4) else self.to_sint(val)
val = (self.to_uint(val)
if m.group(4)
or val >= -INTMAX_MIN and m.group(3) is None
else self.to_sint(val))
return val
if tok.type == 'CPP_STRING':