mirror of
https://github.com/cc65/cc65.git
synced 2024-12-24 11:31:31 +00:00
Small fixes according to PR review.
This commit is contained in:
parent
35e1efc7f2
commit
0f412b6beb
@ -278,7 +278,8 @@ long GetIntegerTypeMin (const Type* Type)
|
||||
/* Get the smallest possible value of the integer type */
|
||||
{
|
||||
if (IsSignSigned (Type)) {
|
||||
return (long)(0xFFFFFFFF << (CHAR_BITS * SizeOf (Type) - 1U));
|
||||
/* The smallest possible signed value of N-byte integer is -pow(2, 8*N-1) */
|
||||
return (long)((unsigned long)(-1L) << (CHAR_BITS * SizeOf (Type) - 1U));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -290,9 +291,14 @@ unsigned long GetIntegerTypeMax (const Type* Type)
|
||||
/* Get the largest possible value of the integer type */
|
||||
{
|
||||
if (IsSignSigned (Type)) {
|
||||
/* Min signed value of N-byte integer is pow(2, 8*N-1) - 1 */
|
||||
return (1UL << (CHAR_BITS * SizeOf (Type) - 1U)) - 1UL;
|
||||
} else {
|
||||
return (1UL << (CHAR_BITS * SizeOf (Type))) - 1UL;
|
||||
/* Max signed value of N-byte integer is pow(2, 8*N) - 1. However,
|
||||
** workaround is needed as in ISO C it is UB if the shift count is
|
||||
** equal to the bit width of the left operand type.
|
||||
*/
|
||||
return (1UL << 1U << (CHAR_BITS * SizeOf (Type) - 1U)) - 1UL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ static int ParseFieldWidth (Declaration* Decl)
|
||||
ConstAbsIntExpr (hie1, &Expr);
|
||||
if (!IsClassInt (Decl->Type)) {
|
||||
/* Only integer types may be used for bit-fields */
|
||||
Error ("Bit-field has invalid type ''");
|
||||
Error ("Bit-field has invalid type '%s'", GetBasicTypeName (Decl->Type));
|
||||
return -1;
|
||||
}
|
||||
if (Expr.IVal < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user