mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +00:00
Fixed SC_* type masks by making them all bitwise-exclusive.
This commit is contained in:
parent
e4fc7a0fec
commit
0250c87ac6
@ -112,7 +112,7 @@ static void Parse (void)
|
||||
ParseDeclSpec (&Spec, SC_EXTERN | SC_STATIC, T_INT);
|
||||
|
||||
/* Don't accept illegal storage classes */
|
||||
if ((Spec.StorageClass & SC_TYPE) == 0) {
|
||||
if ((Spec.StorageClass & SC_TYPEMASK) == 0) {
|
||||
if ((Spec.StorageClass & SC_AUTO) != 0 ||
|
||||
(Spec.StorageClass & SC_REGISTER) != 0) {
|
||||
Error ("Illegal storage class");
|
||||
|
@ -490,7 +490,7 @@ static void ParseEnumDecl (void)
|
||||
}
|
||||
|
||||
/* Add an entry to the symbol table */
|
||||
AddConstSym (Ident, type_int, SC_ENUM, EnumVal++);
|
||||
AddConstSym (Ident, type_int, SC_ENUM|SC_CONST, EnumVal++);
|
||||
|
||||
/* Check for end of definition */
|
||||
if (CurTok.Tok != TOK_COMMA)
|
||||
|
@ -758,7 +758,7 @@ static void Primary (ExprDesc* E)
|
||||
|
||||
/* Check for illegal symbol types */
|
||||
CHECK ((Sym->Flags & SC_LABEL) != SC_LABEL);
|
||||
if (Sym->Flags & SC_TYPE) {
|
||||
if (Sym->Flags & SC_ESUTYPEMASK) {
|
||||
/* Cannot use type symbols */
|
||||
Error ("Variable identifier expected");
|
||||
/* Assume an int type to make E valid */
|
||||
|
@ -69,39 +69,42 @@ struct CodeEntry;
|
||||
|
||||
|
||||
/* Storage classes and flags */
|
||||
#define SC_AUTO 0x0001U /* Auto variable */
|
||||
#define SC_REGISTER 0x0002U /* Register variable */
|
||||
#define SC_STATIC 0x0004U /* Static */
|
||||
#define SC_EXTERN 0x0008U /* Extern linkage */
|
||||
#define SC_NONE 0x0000U /* Nothing */
|
||||
#define SC_STRUCT 0x0001U /* Struct */
|
||||
#define SC_UNION 0x0002U /* Union */
|
||||
#define SC_TYPEDEF 0x0004U /* A typedef */
|
||||
#define SC_ESUTYPEMASK 0x0007U /* Mask for above types */
|
||||
#define SC_ENUM 0x0008U /* An enum */
|
||||
#define SC_BITFIELD 0x0010U /* A bit-field inside a struct or union */
|
||||
#define SC_TYPEMASK 0x001FU /* Mask for above types */
|
||||
|
||||
#define SC_ENUM 0x0030U /* An enum */
|
||||
#define SC_CONST 0x0020U /* A numeric constant with a type */
|
||||
#define SC_LABEL 0x0040U /* A goto label */
|
||||
#define SC_LABEL 0x0040U /* A goto code label */
|
||||
#define SC_PARAM 0x0080U /* A function parameter */
|
||||
#define SC_FUNC 0x0100U /* A function */
|
||||
|
||||
#define SC_DEFTYPE 0x0200U /* Parameter has default type (=int, old style) */
|
||||
#define SC_STORAGE 0x0400U /* Symbol with associated storage */
|
||||
#define SC_DEFAULT 0x0800U /* Flag: default storage class was used */
|
||||
#define SC_STRUCTFIELD 0x0400U /* Struct or union field */
|
||||
|
||||
#define SC_DECL 0x0800U /* Symbol is declared in global scope */
|
||||
|
||||
#define SC_DEF 0x1000U /* Symbol is defined */
|
||||
#define SC_REF 0x2000U /* Symbol is referenced */
|
||||
|
||||
#define SC_TYPE 0x4000U /* This is a type, struct, typedef, etc. */
|
||||
#define SC_STRUCT 0x4001U /* Struct */
|
||||
#define SC_UNION 0x4002U /* Union */
|
||||
#define SC_STRUCTFIELD 0x4003U /* Struct or union field */
|
||||
#define SC_BITFIELD 0x4004U /* A bit-field inside a struct or union */
|
||||
#define SC_TYPEDEF 0x4005U /* A typedef */
|
||||
#define SC_TYPEMASK 0x400FU /* Mask for above types */
|
||||
#define SC_ZEROPAGE 0x4000U /* Symbol marked as zeropage */
|
||||
|
||||
#define SC_ZEROPAGE 0x8000U /* Symbol marked as zeropage */
|
||||
#define SC_STORAGE 0x8000U /* Symbol with associated storage */
|
||||
|
||||
#define SC_HAVEATTR 0x10000U /* Symbol has attributes */
|
||||
#define SC_AUTO 0x010000U /* Auto variable */
|
||||
#define SC_REGISTER 0x020000U /* Register variable */
|
||||
#define SC_STATIC 0x040000U /* Static - not to be confused with other *_STATIC */
|
||||
#define SC_EXTERN 0x080000U /* Extern linkage */
|
||||
#define SC_STORAGEMASK 0x0F0000U /* Storage type mask */
|
||||
|
||||
#define SC_GOTO 0x20000U
|
||||
#define SC_SPADJUSTMENT 0x40000U
|
||||
#define SC_GOTO_IND 0x80000U /* Indirect goto */
|
||||
#define SC_HAVEATTR 0x100000U /* Symbol has attributes */
|
||||
|
||||
#define SC_GOTO 0x200000U
|
||||
#define SC_SPADJUSTMENT 0x400000U
|
||||
#define SC_GOTO_IND 0x800000U /* Indirect goto */
|
||||
|
||||
|
||||
|
||||
@ -245,10 +248,10 @@ INLINE int SymIsRegVar (const SymEntry* Sym)
|
||||
/* Return true if the given entry is a register variable */
|
||||
/* ### HACK! Fix the ugly type flags! */
|
||||
{
|
||||
return ((Sym->Flags & (SC_REGISTER|SC_TYPE)) == SC_REGISTER);
|
||||
return ((Sym->Flags & (SC_REGISTER|SC_TYPEMASK)) == SC_REGISTER);
|
||||
}
|
||||
#else
|
||||
# define SymIsRegVar(Sym) (((Sym)->Flags & (SC_REGISTER|SC_TYPE)) == SC_REGISTER)
|
||||
# define SymIsRegVar(Sym) (((Sym)->Flags & (SC_REGISTER|SC_ESUTYPEMASK)) == SC_REGISTER)
|
||||
#endif
|
||||
|
||||
int SymIsOutputFunc (const SymEntry* Sym);
|
||||
|
@ -821,7 +821,7 @@ SymEntry* AddLocalSym (const char* Name, const Type* T, unsigned Flags, int Offs
|
||||
|
||||
/* Set the symbol attributes */
|
||||
Entry->Type = TypeDup (T);
|
||||
if ((Flags & SC_AUTO) == SC_AUTO) {
|
||||
if ((Flags & SC_AUTO) == SC_AUTO || (Flags & SC_TYPEDEF) == SC_TYPEDEF) {
|
||||
Entry->V.Offs = Offs;
|
||||
} else if ((Flags & SC_REGISTER) == SC_REGISTER) {
|
||||
Entry->V.R.RegOffs = Offs;
|
||||
@ -872,7 +872,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
|
||||
}
|
||||
|
||||
/* We have a symbol with this name already */
|
||||
if (Entry->Flags & SC_TYPE) {
|
||||
if (Entry->Flags & SC_TYPEMASK) {
|
||||
Error ("Multiple definition for '%s'", Name);
|
||||
return Entry;
|
||||
}
|
||||
@ -1109,7 +1109,7 @@ void EmitDebugInfo (void)
|
||||
}
|
||||
Sym = SymTab->SymHead;
|
||||
while (Sym) {
|
||||
if ((Sym->Flags & (SC_CONST|SC_TYPE)) == 0) {
|
||||
if ((Sym->Flags & (SC_CONST|SC_TYPEMASK)) == 0) {
|
||||
if (Sym->Flags & SC_AUTO) {
|
||||
AddTextLine ("%s, \"%s\", \"00\", auto, %d",
|
||||
Head, Sym->Name, Sym->V.Offs);
|
||||
|
Loading…
Reference in New Issue
Block a user