mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 06:25:17 +00:00
Forbid struct/union fields of incomplete types.
This commit is contained in:
@@ -911,8 +911,15 @@ static SymEntry* ParseUnionDecl (const char* Name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for incomplete type */
|
||||||
|
if (IsIncompleteESUType (Decl.Type)) {
|
||||||
|
Error ("Field '%s' has incomplete type '%s'",
|
||||||
|
Decl.Ident,
|
||||||
|
GetFullTypeName (Decl.Type));
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle sizes */
|
/* Handle sizes */
|
||||||
FieldSize = CheckedSizeOf (Decl.Type);
|
FieldSize = SizeOf (Decl.Type);
|
||||||
if (FieldSize > UnionSize) {
|
if (FieldSize > UnionSize) {
|
||||||
UnionSize = FieldSize;
|
UnionSize = FieldSize;
|
||||||
}
|
}
|
||||||
@@ -1095,6 +1102,13 @@ static SymEntry* ParseStructDecl (const char* Name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for incomplete type */
|
||||||
|
if (IsIncompleteESUType (Decl.Type)) {
|
||||||
|
Error ("Field '%s' has incomplete type '%s'",
|
||||||
|
Decl.Ident,
|
||||||
|
GetFullTypeName (Decl.Type));
|
||||||
|
}
|
||||||
|
|
||||||
/* Add a field entry to the table */
|
/* Add a field entry to the table */
|
||||||
if (FieldWidth > 0) {
|
if (FieldWidth > 0) {
|
||||||
/* Full bytes have already been added to the StructSize,
|
/* Full bytes have already been added to the StructSize,
|
||||||
@@ -1119,7 +1133,7 @@ static SymEntry* ParseStructDecl (const char* Name)
|
|||||||
AddLocalSym (Decl.Ident, Decl.Type, SC_STRUCTFIELD, StructSize);
|
AddLocalSym (Decl.Ident, Decl.Type, SC_STRUCTFIELD, StructSize);
|
||||||
}
|
}
|
||||||
if (!FlexibleMember) {
|
if (!FlexibleMember) {
|
||||||
StructSize += CheckedSizeOf (Decl.Type);
|
StructSize += SizeOf (Decl.Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user