1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-15 17:30:06 +00:00

Disabled using non-int-size types to declare bit-fields.

This commit is contained in:
acqn 2020-07-28 11:17:17 +08:00 committed by Oliver Schmidt
parent c37f9f1a41
commit cbb33f86e8
2 changed files with 27 additions and 10 deletions

View File

@ -601,6 +601,26 @@ INLINE int IsSignSigned (const Type* T)
# define IsSignSigned(T) (GetSignedness (T) == T_SIGN_SIGNED)
#endif
#if defined(HAVE_INLINE)
INLINE TypeCode GetRawSizeModifier(const Type* T)
/* Get the size modifier of a raw type */
{
return (T->C & T_MASK_SIZE);
}
#else
# define GetRawSizeModifier(T) ((T)->C & T_MASK_SIZE)
#endif
#if defined(HAVE_INLINE)
INLINE TypeCode GetSizeModifier (const Type* T)
/* Get the size modifier of a type */
{
return (GetUnderlyingTypeCode (T) & T_MASK_SIZE);
}
#else
# define GetSizeModifier(T) (GetUnderlyingTypeCode (T) & T_MASK_SIZE)
#endif
#if defined(HAVE_INLINE)
INLINE TypeCode GetQualifier (const Type* T)
/* Get the qualifier from the given type string */
@ -696,16 +716,6 @@ int IsVariadicFunc (const Type* T) attribute ((const));
** variable parameter list
*/
#if defined(HAVE_INLINE)
INLINE TypeCode GetSizeModifier (const Type* T)
/* Get the size modifier of a type */
{
return (T->C & T_MASK_SIZE);
}
#else
# define GetSizeModifier(T) ((T)->C & T_MASK_SIZE)
#endif
FuncDesc* GetFuncDesc (const Type* T) attribute ((const));
/* Get the FuncDesc pointer from a function or pointer-to-function type */

View File

@ -689,6 +689,13 @@ static int ParseFieldWidth (Declaration* Decl)
Error ("Bit-field has invalid type '%s'", GetBasicTypeName (Decl->Type));
return -1;
}
if (SizeOf (Decl->Type) != SizeOf (type_uint)) {
/* Only int sized types may be used for bit-fields for now */
Error ("CC65 currently only supports unsigned int bit-fields");
return -1;
}
if (Expr.IVal < 0) {
Error ("Negative width in bit-field");
return -1;