1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-06 12:31:12 +00:00

Merge pull request #2236 from acqn/TypeFix

[cc65] Fixed some type-related bugs which don't have any impact yet
This commit is contained in:
Bob Andrews 2023-10-29 12:37:07 +01:00 committed by GitHub
commit f381d23001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -63,6 +63,8 @@
const Type type_char[] = { TYPE(T_CHAR), TYPE(T_END) };
const Type type_schar[] = { TYPE(T_SCHAR), TYPE(T_END) };
const Type type_uchar[] = { TYPE(T_UCHAR), TYPE(T_END) };
const Type type_short[] = { TYPE(T_SHORT), TYPE(T_END) };
const Type type_ushort[] = { TYPE(T_USHORT), TYPE(T_END) };
const Type type_int[] = { TYPE(T_INT), TYPE(T_END) };
const Type type_uint[] = { TYPE(T_UINT), TYPE(T_END) };
const Type type_long[] = { TYPE(T_LONG), TYPE(T_END) };
@ -315,7 +317,7 @@ unsigned CheckedSizeOf (const Type* T)
{
unsigned Size = SizeOf (T);
if (Size == 0) {
if (HasUnknownSize (T + 1)) {
if (HasUnknownSize (T)) {
Error ("Size of type '%s' is unknown", GetFullTypeName (T));
} else {
Error ("Size of type '%s' is 0", GetFullTypeName (T));
@ -727,8 +729,10 @@ const Type* GetSignedType (const Type* T)
case T_RANK_CHAR:
return type_schar;
case T_RANK_INT:
case T_RANK_SHORT:
return type_short;
case T_RANK_INT:
return type_int;
case T_RANK_LONG:
@ -749,8 +753,10 @@ const Type* GetUnsignedType (const Type* T)
case T_RANK_CHAR:
return type_uchar;
case T_RANK_INT:
case T_RANK_SHORT:
return type_ushort;
case T_RANK_INT:
return type_uint;
case T_RANK_LONG:
@ -1016,7 +1022,11 @@ int HasUnknownSize (const Type* T)
int TypeHasAttrData (const Type* T)
/* Return true if the given type has attribute data */
{
return IsClassStruct (T) || IsTypeArray (T) || IsClassFunc (T);
return IsClassStruct (T) ||
IsTypeArray (T) ||
IsClassFunc (T) ||
IsTypeVoid (T) ||
IsTypeBitField (T);
}

View File

@ -215,6 +215,8 @@ struct Type {
extern const Type type_char[];
extern const Type type_schar[];
extern const Type type_uchar[];
extern const Type type_short[];
extern const Type type_ushort[];
extern const Type type_int[];
extern const Type type_uint[];
extern const Type type_long[];

View File

@ -759,7 +759,7 @@ static SymEntry* ParseEnumSpec (const char* Name, unsigned* DSFlags)
Flags |= SC_FICTITIOUS;
}
return AddEnumSym (Name, Flags, MemberType, FieldTab, DSFlags);
return AddEnumSym (Name, SC_DEF | Flags, MemberType, FieldTab, DSFlags);
}