mirror of
https://github.com/cc65/cc65.git
synced 2025-08-10 20:25:20 +00:00
Make struct work as documented
git-svn-id: svn://svn.cc65.org/cc65/trunk@2716 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -83,6 +83,11 @@ static long Member (long AllocSize)
|
|||||||
AllocSize *= Multiplicator;
|
AllocSize *= Multiplicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check the size for a reasonable value */
|
||||||
|
if (AllocSize >= 0x10000) {
|
||||||
|
Error ("Range error");
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the size */
|
/* Return the size */
|
||||||
return AllocSize;
|
return AllocSize;
|
||||||
}
|
}
|
||||||
@@ -99,13 +104,7 @@ static long DoStructInternal (long Offs, unsigned Type)
|
|||||||
* is started.
|
* is started.
|
||||||
*/
|
*/
|
||||||
int Anon = (Tok != TOK_IDENT);
|
int Anon = (Tok != TOK_IDENT);
|
||||||
if (Anon) {
|
if (!Anon) {
|
||||||
unsigned char T = GetCurrentSymTabType ();
|
|
||||||
if (T != ST_STRUCT) {
|
|
||||||
ErrorSkip ("Struct/union needs a name");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Enter a new scope, then skip the name */
|
/* Enter a new scope, then skip the name */
|
||||||
SymEnterLevel (SVal, ST_STRUCT, ADDR_SIZE_ABS);
|
SymEnterLevel (SVal, ST_STRUCT, ADDR_SIZE_ABS);
|
||||||
NextTok ();
|
NextTok ();
|
||||||
@@ -178,10 +177,8 @@ static long DoStructInternal (long Offs, unsigned Type)
|
|||||||
Error ("Not a struct/union");
|
Error ("Not a struct/union");
|
||||||
} else {
|
} else {
|
||||||
SymEntry* SizeSym = GetSizeOfScope (Struct);
|
SymEntry* SizeSym = GetSizeOfScope (Struct);
|
||||||
if (!SymIsDef (SizeSym)) {
|
if (!SymIsDef (SizeSym) || !SymIsConst (SizeSym, &MemberSize)) {
|
||||||
Error ("Size of struct/union is unknown");
|
Error ("Size of struct/union is unknown");
|
||||||
} else {
|
|
||||||
MemberSize = GetSymVal (SizeSym);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MemberSize *= Member (MemberSize);
|
MemberSize *= Member (MemberSize);
|
||||||
|
Reference in New Issue
Block a user