mirror of
https://github.com/cc65/cc65.git
synced 2025-02-18 15:30:30 +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 */
|
/* Get the smallest possible value of the integer type */
|
||||||
{
|
{
|
||||||
if (IsSignSigned (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 {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -290,9 +291,14 @@ unsigned long GetIntegerTypeMax (const Type* Type)
|
|||||||
/* Get the largest possible value of the integer type */
|
/* Get the largest possible value of the integer type */
|
||||||
{
|
{
|
||||||
if (IsSignSigned (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;
|
return (1UL << (CHAR_BITS * SizeOf (Type) - 1U)) - 1UL;
|
||||||
} else {
|
} 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);
|
ConstAbsIntExpr (hie1, &Expr);
|
||||||
if (!IsClassInt (Decl->Type)) {
|
if (!IsClassInt (Decl->Type)) {
|
||||||
/* Only integer types may be used for bit-fields */
|
/* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
if (Expr.IVal < 0) {
|
if (Expr.IVal < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user