From: uz Date: Mon, 19 Oct 2009 10:19:26 +0000 (+0000) Subject: Renamed attribute handling functions. Added SymHasAttr(). X-Git-Tag: V2.13.1~150 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=548336a7bdbf244c3ac6ce5f45e9092486a372dc;p=cc65 Renamed attribute handling functions. Added SymHasAttr(). git-svn-id: svn://svn.cc65.org/cc65/trunk@4375 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 7144edb81..3dd7bffa4 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -170,7 +170,7 @@ static void Parse (void) Entry = AddGlobalSym (Decl.Ident, Decl.Type, Decl.StorageClass); /* Add declaration attributes */ - SymUseAttributes (Entry, &Decl); + SymUseAttr (Entry, &Decl); /* Reserve storage for the variable if we need to */ if (Decl.StorageClass & SC_STORAGE) { diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 0748aa5cb..1e0b610ed 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1169,7 +1169,7 @@ static void ParseAnsiParamList (FuncDesc* F) Sym = AddLocalSym (Decl.Ident, ParamTypeCvt (Decl.Type), Decl.StorageClass, 0); /* Add attributes if we have any */ - SymUseAttributes (Sym, &Decl); + SymUseAttr (Sym, &Decl); /* If the parameter is a struct or union, emit a warning */ if (IsClassStruct (Decl.Type)) { diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 8b5069b34..27a8469a5 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -487,7 +487,7 @@ static void FunctionCall (ExprDesc* Expr) } else { /* Check function attributes */ - if (Expr->Sym && SymGetAttribute (Expr->Sym, atNoReturn)) { + if (Expr->Sym && SymHasAttr (Expr->Sym, atNoReturn)) { /* For now, handle as if a return statement was encountered */ F_ReturnFound (CurrentFunc); } diff --git a/src/cc65/symentry.c b/src/cc65/symentry.c index 6ad4a5cfc..aedf2652e 100644 --- a/src/cc65/symentry.c +++ b/src/cc65/symentry.c @@ -153,7 +153,7 @@ void DumpSymEntry (FILE* F, const SymEntry* E) -const DeclAttr* SymGetAttribute (const SymEntry* Sym, DeclAttrType AttrType) +const DeclAttr* SymGetAttr (const SymEntry* Sym, DeclAttrType AttrType) /* Return an attribute for this symbol or NULL if the attribute does not exist */ { /* Beware: We may not even have a collection */ @@ -177,7 +177,7 @@ const DeclAttr* SymGetAttribute (const SymEntry* Sym, DeclAttrType AttrType) -void SymUseAttributes (SymEntry* Sym, struct Declaration* D) +void SymUseAttr (SymEntry* Sym, struct Declaration* D) /* Use the attributes from the declaration for this symbol */ { /* We cannot specify attributes twice */ diff --git a/src/cc65/symentry.h b/src/cc65/symentry.h index 06e5a0e87..d83113809 100644 --- a/src/cc65/symentry.h +++ b/src/cc65/symentry.h @@ -231,10 +231,20 @@ INLINE const char* SymGetAsmName (const SymEntry* Sym) # define SymGetAsmName(Sym) ((Sym)->AsmName) #endif -const DeclAttr* SymGetAttribute (const SymEntry* Sym, DeclAttrType AttrType); +const DeclAttr* SymGetAttr (const SymEntry* Sym, DeclAttrType AttrType); /* Return an attribute for this symbol or NULL if the attribute does not exist */ -void SymUseAttributes (SymEntry* Sym, struct Declaration* D); +#if defined(HAVE_INLINE) +INLINE int SymHasAttr (const SymEntry* Sym, DeclAttrType A) +/* Return true if the symbol has the given attribute */ +{ + return (SymGetAttr (Sym, A) != 0); +} +#else +# define SymHasAttr(Sym, A) (SymGetAttr (Sym, A) != 0) +#endif + +void SymUseAttr (SymEntry* Sym, struct Declaration* D); /* Use the attributes from the declaration for this symbol */ void CvtRegVarToAuto (SymEntry* Sym); diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index f02f9a6b6..5a7c740d3 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -162,8 +162,8 @@ static void CheckSymTable (SymTable* Tab) * defined but not used. */ if (((Flags & SC_AUTO) || (Flags & SC_STATIC)) && (Flags & SC_EXTERN) == 0) { - if (SymIsDef (Entry) && !SymIsRef (Entry) && - SymGetAttribute (Entry, atUnused) == 0) { + if (SymIsDef (Entry) && !SymIsRef (Entry) && + !SymHasAttr (Entry, atUnused)) { if (Flags & SC_PARAM) { if (IS_Get (&WarnUnusedParam)) { Warning ("Parameter `%s' is never used", Entry->Name);