mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 17:30:50 +00:00
Renamed a few functions and struct used for declaration parser.
This commit is contained in:
parent
800c30604f
commit
e10b5fd79b
@ -146,7 +146,7 @@ static void Parse (void)
|
|||||||
comma = 0;
|
comma = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
Declaration Decl;
|
Declarator Decl;
|
||||||
|
|
||||||
/* Read the next declaration */
|
/* Read the next declaration */
|
||||||
ParseDecl (&Spec, &Decl, DM_NEED_IDENT);
|
ParseDecl (&Spec, &Decl, DM_NEED_IDENT);
|
||||||
|
@ -356,8 +356,8 @@ void InitDeclSpec (DeclSpec* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void InitDeclaration (Declaration* D)
|
static void InitDeclarator (Declarator* D)
|
||||||
/* Initialize the Declaration struct for use */
|
/* Initialize the Declarator struct for use */
|
||||||
{
|
{
|
||||||
D->Ident[0] = '\0';
|
D->Ident[0] = '\0';
|
||||||
D->Type[0].C = T_END;
|
D->Type[0].C = T_END;
|
||||||
@ -367,7 +367,7 @@ static void InitDeclaration (Declaration* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void NeedTypeSpace (Declaration* D, unsigned Count)
|
static void NeedTypeSpace (Declarator* D, unsigned Count)
|
||||||
/* Check if there is enough space for Count type specifiers within D */
|
/* Check if there is enough space for Count type specifiers within D */
|
||||||
{
|
{
|
||||||
if (D->Index + Count >= MAXTYPELEN) {
|
if (D->Index + Count >= MAXTYPELEN) {
|
||||||
@ -381,8 +381,8 @@ static void NeedTypeSpace (Declaration* D, unsigned Count)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void AddTypeToDeclaration (Declaration* D, TypeCode T)
|
static void AddTypeCodeToDeclarator (Declarator* D, TypeCode T)
|
||||||
/* Add a type specifier to the type of a declaration */
|
/* Add a type specifier to the type of a declarator */
|
||||||
{
|
{
|
||||||
NeedTypeSpace (D, 1);
|
NeedTypeSpace (D, 1);
|
||||||
D->Type[D->Index++].C = T;
|
D->Type[D->Index++].C = T;
|
||||||
@ -524,8 +524,8 @@ static void CheckArrayElementType (Type* DataType)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static SymEntry* ESUForwardDecl (const char* Name, unsigned Flags, unsigned* DSFlags)
|
static SymEntry* ForwardESU (const char* Name, unsigned Flags, unsigned* DSFlags)
|
||||||
/* Handle an enum, struct or union forward decl */
|
/* Handle an enum, struct or union forward declaration */
|
||||||
{
|
{
|
||||||
/* Try to find an enum/struct/union with the given name. If there is none,
|
/* Try to find an enum/struct/union with the given name. If there is none,
|
||||||
** insert a forward declaration into the current lexical level.
|
** insert a forward declaration into the current lexical level.
|
||||||
@ -584,8 +584,8 @@ static const Type* GetEnumeratorType (long Min, unsigned long Max, int Signed)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static SymEntry* ParseEnumDecl (const char* Name, unsigned* DSFlags)
|
static SymEntry* ParseEnumSpec (const char* Name, unsigned* DSFlags)
|
||||||
/* Process an enum declaration */
|
/* Process an enum specifier */
|
||||||
{
|
{
|
||||||
SymTable* FieldTab;
|
SymTable* FieldTab;
|
||||||
long EnumVal;
|
long EnumVal;
|
||||||
@ -602,7 +602,7 @@ static SymEntry* ParseEnumDecl (const char* Name, unsigned* DSFlags)
|
|||||||
|
|
||||||
if (CurTok.Tok != TOK_LCURLY) {
|
if (CurTok.Tok != TOK_LCURLY) {
|
||||||
/* Just a forward definition */
|
/* Just a forward definition */
|
||||||
return ESUForwardDecl (Name, SC_ENUM, DSFlags);
|
return ForwardESU (Name, SC_ENUM, DSFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a forward declaration for the enum tag in the current lexical level */
|
/* Add a forward declaration for the enum tag in the current lexical level */
|
||||||
@ -754,7 +754,7 @@ static SymEntry* ParseEnumDecl (const char* Name, unsigned* DSFlags)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ParseFieldWidth (Declaration* D)
|
static int ParseFieldWidth (Declarator* D)
|
||||||
/* Parse an optional field width. Returns -1 if no field width is specified,
|
/* Parse an optional field width. Returns -1 if no field width is specified,
|
||||||
** otherwise the width of the field.
|
** otherwise the width of the field.
|
||||||
*/
|
*/
|
||||||
@ -832,7 +832,7 @@ static unsigned PadWithBitField (unsigned StructSize, unsigned BitOffs)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned AliasAnonStructFields (const Declaration* D, SymEntry* Anon)
|
static unsigned AliasAnonStructFields (const Declarator* D, SymEntry* Anon)
|
||||||
/* Create alias fields from an anon union/struct in the current lexical level.
|
/* Create alias fields from an anon union/struct in the current lexical level.
|
||||||
** The function returns the count of created aliases.
|
** The function returns the count of created aliases.
|
||||||
*/
|
*/
|
||||||
@ -879,8 +879,8 @@ static unsigned AliasAnonStructFields (const Declaration* D, SymEntry* Anon)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static SymEntry* ParseUnionDecl (const char* Name, unsigned* DSFlags)
|
static SymEntry* ParseUnionSpec (const char* Name, unsigned* DSFlags)
|
||||||
/* Parse a union declaration. */
|
/* Parse a union specifier */
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned UnionSize;
|
unsigned UnionSize;
|
||||||
@ -895,7 +895,7 @@ static SymEntry* ParseUnionDecl (const char* Name, unsigned* DSFlags)
|
|||||||
|
|
||||||
if (CurTok.Tok != TOK_LCURLY) {
|
if (CurTok.Tok != TOK_LCURLY) {
|
||||||
/* Just a forward declaration */
|
/* Just a forward declaration */
|
||||||
return ESUForwardDecl (Name, SC_UNION, DSFlags);
|
return ForwardESU (Name, SC_UNION, DSFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a forward declaration for the union tag in the current lexical level */
|
/* Add a forward declaration for the union tag in the current lexical level */
|
||||||
@ -929,7 +929,7 @@ static SymEntry* ParseUnionDecl (const char* Name, unsigned* DSFlags)
|
|||||||
/* Read fields with this type */
|
/* Read fields with this type */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
Declaration Decl;
|
Declarator Decl;
|
||||||
|
|
||||||
/* Get type and name of the struct field */
|
/* Get type and name of the struct field */
|
||||||
ParseDecl (&Spec, &Decl, DM_ACCEPT_IDENT);
|
ParseDecl (&Spec, &Decl, DM_ACCEPT_IDENT);
|
||||||
@ -1026,8 +1026,8 @@ NextMember: if (CurTok.Tok != TOK_COMMA) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static SymEntry* ParseStructDecl (const char* Name, unsigned* DSFlags)
|
static SymEntry* ParseStructSpec (const char* Name, unsigned* DSFlags)
|
||||||
/* Parse a struct declaration. */
|
/* Parse a struct specifier */
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned StructSize;
|
unsigned StructSize;
|
||||||
@ -1043,7 +1043,7 @@ static SymEntry* ParseStructDecl (const char* Name, unsigned* DSFlags)
|
|||||||
|
|
||||||
if (CurTok.Tok != TOK_LCURLY) {
|
if (CurTok.Tok != TOK_LCURLY) {
|
||||||
/* Just a forward declaration */
|
/* Just a forward declaration */
|
||||||
return ESUForwardDecl (Name, SC_STRUCT, DSFlags);
|
return ForwardESU (Name, SC_STRUCT, DSFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a forward declaration for the struct tag in the current lexical level */
|
/* Add a forward declaration for the struct tag in the current lexical level */
|
||||||
@ -1079,7 +1079,7 @@ static SymEntry* ParseStructDecl (const char* Name, unsigned* DSFlags)
|
|||||||
/* Read fields with this type */
|
/* Read fields with this type */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
Declaration Decl;
|
Declarator Decl;
|
||||||
|
|
||||||
/* If we had a flexible array member before, no other fields can
|
/* If we had a flexible array member before, no other fields can
|
||||||
** follow.
|
** follow.
|
||||||
@ -1418,7 +1418,7 @@ static void ParseTypeSpec (DeclSpec* D, typespec_t TSFlags, int* SignednessSpeci
|
|||||||
/* Remember we have an extra type decl */
|
/* Remember we have an extra type decl */
|
||||||
D->Flags |= DS_EXTRA_TYPE;
|
D->Flags |= DS_EXTRA_TYPE;
|
||||||
/* Declare the union in the current scope */
|
/* Declare the union in the current scope */
|
||||||
TagEntry = ParseUnionDecl (Ident, &D->Flags);
|
TagEntry = ParseUnionSpec (Ident, &D->Flags);
|
||||||
/* Encode the union entry into the type */
|
/* Encode the union entry into the type */
|
||||||
D->Type[0].C = T_UNION;
|
D->Type[0].C = T_UNION;
|
||||||
SetESUTagSym (D->Type, TagEntry);
|
SetESUTagSym (D->Type, TagEntry);
|
||||||
@ -1437,7 +1437,7 @@ static void ParseTypeSpec (DeclSpec* D, typespec_t TSFlags, int* SignednessSpeci
|
|||||||
/* Remember we have an extra type decl */
|
/* Remember we have an extra type decl */
|
||||||
D->Flags |= DS_EXTRA_TYPE;
|
D->Flags |= DS_EXTRA_TYPE;
|
||||||
/* Declare the struct in the current scope */
|
/* Declare the struct in the current scope */
|
||||||
TagEntry = ParseStructDecl (Ident, &D->Flags);
|
TagEntry = ParseStructSpec (Ident, &D->Flags);
|
||||||
/* Encode the struct entry into the type */
|
/* Encode the struct entry into the type */
|
||||||
D->Type[0].C = T_STRUCT;
|
D->Type[0].C = T_STRUCT;
|
||||||
SetESUTagSym (D->Type, TagEntry);
|
SetESUTagSym (D->Type, TagEntry);
|
||||||
@ -1460,7 +1460,7 @@ static void ParseTypeSpec (DeclSpec* D, typespec_t TSFlags, int* SignednessSpeci
|
|||||||
/* Remember we have an extra type decl */
|
/* Remember we have an extra type decl */
|
||||||
D->Flags |= DS_EXTRA_TYPE;
|
D->Flags |= DS_EXTRA_TYPE;
|
||||||
/* Parse the enum decl */
|
/* Parse the enum decl */
|
||||||
TagEntry = ParseEnumDecl (Ident, &D->Flags);
|
TagEntry = ParseEnumSpec (Ident, &D->Flags);
|
||||||
/* Encode the enum entry into the type */
|
/* Encode the enum entry into the type */
|
||||||
D->Type[0].C |= T_ENUM;
|
D->Type[0].C |= T_ENUM;
|
||||||
SetESUTagSym (D->Type, TagEntry);
|
SetESUTagSym (D->Type, TagEntry);
|
||||||
@ -1612,7 +1612,7 @@ static void ParseOldStyleParamList (FuncDesc* F)
|
|||||||
/* Parse a comma separated variable list */
|
/* Parse a comma separated variable list */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
Declaration Decl;
|
Declarator Decl;
|
||||||
|
|
||||||
/* Read the parameter */
|
/* Read the parameter */
|
||||||
ParseDecl (&Spec, &Decl, DM_NEED_IDENT);
|
ParseDecl (&Spec, &Decl, DM_NEED_IDENT);
|
||||||
@ -1667,7 +1667,7 @@ static void ParseAnsiParamList (FuncDesc* F)
|
|||||||
while (CurTok.Tok != TOK_RPAREN) {
|
while (CurTok.Tok != TOK_RPAREN) {
|
||||||
|
|
||||||
DeclSpec Spec;
|
DeclSpec Spec;
|
||||||
Declaration Decl;
|
Declarator Decl;
|
||||||
SymEntry* Param;
|
SymEntry* Param;
|
||||||
|
|
||||||
/* Allow an ellipsis as last parameter */
|
/* Allow an ellipsis as last parameter */
|
||||||
@ -1748,7 +1748,7 @@ static void ParseAnsiParamList (FuncDesc* F)
|
|||||||
|
|
||||||
|
|
||||||
static FuncDesc* ParseFuncDecl (void)
|
static FuncDesc* ParseFuncDecl (void)
|
||||||
/* Parse the argument list of a function. */
|
/* Parse the argument list of a function with the enclosing parentheses */
|
||||||
{
|
{
|
||||||
SymEntry* Sym;
|
SymEntry* Sym;
|
||||||
SymEntry* WrappedCall;
|
SymEntry* WrappedCall;
|
||||||
@ -1760,6 +1760,9 @@ static FuncDesc* ParseFuncDecl (void)
|
|||||||
/* Enter a new lexical level */
|
/* Enter a new lexical level */
|
||||||
EnterFunctionLevel ();
|
EnterFunctionLevel ();
|
||||||
|
|
||||||
|
/* Skip the opening paren */
|
||||||
|
NextToken ();
|
||||||
|
|
||||||
/* Check for several special parameter lists */
|
/* Check for several special parameter lists */
|
||||||
if (CurTok.Tok == TOK_RPAREN) {
|
if (CurTok.Tok == TOK_RPAREN) {
|
||||||
/* Parameter list is empty (K&R-style) */
|
/* Parameter list is empty (K&R-style) */
|
||||||
@ -1817,14 +1820,14 @@ static FuncDesc* ParseFuncDecl (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
|
static void DirectDecl (const DeclSpec* Spec, Declarator* D, declmode_t Mode)
|
||||||
/* Recursively process declarators. Build a type array in reverse order. */
|
/* Recursively process direct declarators. Build a type array in reverse order. */
|
||||||
{
|
{
|
||||||
/* Read optional function or pointer qualifiers. They modify the
|
/* Read optional function or pointer qualifiers that modify the identifier
|
||||||
** identifier or token to the right. For convenience, we allow a calling
|
** or token to the right. For convenience, we allow a calling convention
|
||||||
** convention also for pointers here. If it's a pointer-to-function, the
|
** also for pointers here. If it's a pointer-to-function, the qualifier
|
||||||
** qualifier later will be transfered to the function itself. If it's a
|
** later will be transfered to the function itself. If it's a pointer to
|
||||||
** pointer to something else, it will be flagged as an error.
|
** something else, it will be flagged as an error.
|
||||||
*/
|
*/
|
||||||
TypeCode Qualifiers = OptionalQualifiers (T_QUAL_NONE, T_QUAL_ADDRSIZE | T_QUAL_CCONV);
|
TypeCode Qualifiers = OptionalQualifiers (T_QUAL_NONE, T_QUAL_ADDRSIZE | T_QUAL_CCONV);
|
||||||
|
|
||||||
@ -1838,16 +1841,16 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
|
|||||||
Qualifiers |= OptionalQualifiers (Qualifiers, T_QUAL_CVR);
|
Qualifiers |= OptionalQualifiers (Qualifiers, T_QUAL_CVR);
|
||||||
|
|
||||||
/* Parse the type that the pointer points to */
|
/* Parse the type that the pointer points to */
|
||||||
Declarator (Spec, D, Mode);
|
DirectDecl (Spec, D, Mode);
|
||||||
|
|
||||||
/* Add the type */
|
/* Add the type */
|
||||||
AddTypeToDeclaration (D, T_PTR | Qualifiers);
|
AddTypeCodeToDeclarator (D, T_PTR | Qualifiers);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurTok.Tok == TOK_LPAREN) {
|
if (CurTok.Tok == TOK_LPAREN) {
|
||||||
NextToken ();
|
NextToken ();
|
||||||
Declarator (Spec, D, Mode);
|
DirectDecl (Spec, D, Mode);
|
||||||
ConsumeRParen ();
|
ConsumeRParen ();
|
||||||
} else {
|
} else {
|
||||||
/* Things depend on Mode now:
|
/* Things depend on Mode now:
|
||||||
@ -1876,14 +1879,11 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
|
|||||||
while (CurTok.Tok == TOK_LBRACK || CurTok.Tok == TOK_LPAREN) {
|
while (CurTok.Tok == TOK_LBRACK || CurTok.Tok == TOK_LPAREN) {
|
||||||
if (CurTok.Tok == TOK_LPAREN) {
|
if (CurTok.Tok == TOK_LPAREN) {
|
||||||
|
|
||||||
/* Function declaration */
|
/* Function declarator */
|
||||||
FuncDesc* F;
|
FuncDesc* F;
|
||||||
SymEntry* PrevEntry;
|
SymEntry* PrevEntry;
|
||||||
|
|
||||||
/* Skip the opening paren */
|
/* Parse the function declarator */
|
||||||
NextToken ();
|
|
||||||
|
|
||||||
/* Parse the function declaration */
|
|
||||||
F = ParseFuncDecl ();
|
F = ParseFuncDecl ();
|
||||||
|
|
||||||
/* We cannot specify fastcall for variadic functions */
|
/* We cannot specify fastcall for variadic functions */
|
||||||
@ -1912,7 +1912,7 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
|
|||||||
Qualifiers = T_QUAL_NONE;
|
Qualifiers = T_QUAL_NONE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Array declaration. */
|
/* Array declarator */
|
||||||
long Size = UNSPECIFIED;
|
long Size = UNSPECIFIED;
|
||||||
|
|
||||||
/* We cannot have any qualifiers for an array */
|
/* We cannot have any qualifiers for an array */
|
||||||
@ -1976,7 +1976,7 @@ Type* ParseType (Type* T)
|
|||||||
/* Parse a complete type specification */
|
/* Parse a complete type specification */
|
||||||
{
|
{
|
||||||
DeclSpec Spec;
|
DeclSpec Spec;
|
||||||
Declaration Decl;
|
Declarator Decl;
|
||||||
|
|
||||||
/* Get a type without a default */
|
/* Get a type without a default */
|
||||||
InitDeclSpec (&Spec);
|
InitDeclSpec (&Spec);
|
||||||
@ -1994,19 +1994,19 @@ Type* ParseType (Type* T)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
|
void ParseDecl (const DeclSpec* Spec, Declarator* D, declmode_t Mode)
|
||||||
/* Parse a variable, type or function declaration */
|
/* Parse a variable, type or function declarator */
|
||||||
{
|
{
|
||||||
/* Used to check if we have any errors during parsing this */
|
/* Used to check if we have any errors during parsing this */
|
||||||
unsigned PrevErrorCount = ErrorCount;
|
unsigned PrevErrorCount = ErrorCount;
|
||||||
|
|
||||||
/* Initialize the Declaration struct */
|
/* Initialize the Declarator struct */
|
||||||
InitDeclaration (D);
|
InitDeclarator (D);
|
||||||
|
|
||||||
/* Get additional declarators and the identifier */
|
/* Get additional derivation of the declarator and the identifier */
|
||||||
Declarator (Spec, D, Mode);
|
DirectDecl (Spec, D, Mode);
|
||||||
|
|
||||||
/* Add the base type. */
|
/* Add the base type */
|
||||||
NeedTypeSpace (D, TypeLen (Spec->Type) + 1); /* Bounds check */
|
NeedTypeSpace (D, TypeLen (Spec->Type) + 1); /* Bounds check */
|
||||||
TypeCopy (D->Type + D->Index, Spec->Type);
|
TypeCopy (D->Type + D->Index, Spec->Type);
|
||||||
|
|
||||||
@ -2024,7 +2024,7 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
|
|||||||
D->StorageClass |= SC_FUNC;
|
D->StorageClass |= SC_FUNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse attributes for this declaration */
|
/* Parse attributes for this declarator */
|
||||||
ParseAttribute (D);
|
ParseAttribute (D);
|
||||||
|
|
||||||
/* Check several things for function or function pointer types */
|
/* Check several things for function or function pointer types */
|
||||||
|
@ -86,8 +86,8 @@ struct DeclSpec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Result of ParseDecl */
|
/* Result of ParseDecl */
|
||||||
typedef struct Declaration Declaration;
|
typedef struct Declarator Declarator;
|
||||||
struct Declaration {
|
struct Declarator {
|
||||||
unsigned StorageClass; /* A set of SC_xxx flags */
|
unsigned StorageClass; /* A set of SC_xxx flags */
|
||||||
Type Type[MAXTYPELEN]; /* The type */
|
Type Type[MAXTYPELEN]; /* The type */
|
||||||
ident Ident; /* The identifier, if any*/
|
ident Ident; /* The identifier, if any*/
|
||||||
@ -118,8 +118,8 @@ void InitDeclSpec (DeclSpec* D);
|
|||||||
Type* ParseType (Type* Type);
|
Type* ParseType (Type* Type);
|
||||||
/* Parse a complete type specification */
|
/* Parse a complete type specification */
|
||||||
|
|
||||||
void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode);
|
void ParseDecl (const DeclSpec* Spec, Declarator* D, declmode_t Mode);
|
||||||
/* Parse a variable, type or function declaration */
|
/* Parse a variable, type or function declarator */
|
||||||
|
|
||||||
void ParseDeclSpec (DeclSpec* D, typespec_t TSFlags, unsigned DefStorage);
|
void ParseDeclSpec (DeclSpec* D, typespec_t TSFlags, unsigned DefStorage);
|
||||||
/* Parse a declaration specification */
|
/* Parse a declaration specification */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* declattr.c */
|
/* declattr.c */
|
||||||
/* */
|
/* */
|
||||||
/* Declaration attributes */
|
/* Declarator attributes */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@ -55,8 +55,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Forwards for attribute handlers */
|
/* Forwards for attribute handlers */
|
||||||
static void NoReturnAttr (Declaration* D);
|
static void NoReturnAttr (Declarator* D);
|
||||||
static void UnusedAttr (Declaration* D);
|
static void UnusedAttr (Declarator* D);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ static void UnusedAttr (Declaration* D);
|
|||||||
typedef struct AttrDesc AttrDesc;
|
typedef struct AttrDesc AttrDesc;
|
||||||
struct AttrDesc {
|
struct AttrDesc {
|
||||||
const char Name[15];
|
const char Name[15];
|
||||||
void (*Handler) (Declaration*);
|
void (*Handler) (Declarator*);
|
||||||
};
|
};
|
||||||
static const AttrDesc AttrTable [] = {
|
static const AttrDesc AttrTable [] = {
|
||||||
{ "__noreturn__", NoReturnAttr },
|
{ "__noreturn__", NoReturnAttr },
|
||||||
@ -141,8 +141,8 @@ static void ErrorSkip (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void AddAttr (Declaration* D, DeclAttr* A)
|
static void AddAttr (Declarator* D, DeclAttr* A)
|
||||||
/* Add an attribute to a declaration */
|
/* Add an attribute to a declarator */
|
||||||
{
|
{
|
||||||
/* Allocate the list if necessary, the add the attribute */
|
/* Allocate the list if necessary, the add the attribute */
|
||||||
if (D->Attributes == 0) {
|
if (D->Attributes == 0) {
|
||||||
@ -159,7 +159,7 @@ static void AddAttr (Declaration* D, DeclAttr* A)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void NoReturnAttr (Declaration* D)
|
static void NoReturnAttr (Declarator* D)
|
||||||
/* Parse the "noreturn" attribute */
|
/* Parse the "noreturn" attribute */
|
||||||
{
|
{
|
||||||
/* Add the noreturn attribute */
|
/* Add the noreturn attribute */
|
||||||
@ -168,7 +168,7 @@ static void NoReturnAttr (Declaration* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void UnusedAttr (Declaration* D)
|
static void UnusedAttr (Declarator* D)
|
||||||
/* Parse the "unused" attribute */
|
/* Parse the "unused" attribute */
|
||||||
{
|
{
|
||||||
/* Add the noreturn attribute */
|
/* Add the noreturn attribute */
|
||||||
@ -177,7 +177,7 @@ static void UnusedAttr (Declaration* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ParseAttribute (Declaration* D)
|
void ParseAttribute (Declarator* D)
|
||||||
/* Parse an additional __attribute__ modifier */
|
/* Parse an additional __attribute__ modifier */
|
||||||
{
|
{
|
||||||
/* Do we have an attribute? */
|
/* Do we have an attribute? */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* declattr.h */
|
/* declattr.h */
|
||||||
/* */
|
/* */
|
||||||
/* Declaration attributes */
|
/* Declarator attributes */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Forward */
|
/* Forward */
|
||||||
struct Declaration;
|
struct Declarator;
|
||||||
|
|
||||||
/* Supported attribute types */
|
/* Supported attribute types */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -67,7 +67,7 @@ struct DeclAttr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ParseAttribute (struct Declaration* D);
|
void ParseAttribute (struct Declarator* D);
|
||||||
/* Parse an additional __attribute__ modifier */
|
/* Parse an additional __attribute__ modifier */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1307,7 +1307,7 @@ static void Primary (ExprDesc* E)
|
|||||||
|
|
||||||
Error ("Mixed declarations and code are not supported in cc65");
|
Error ("Mixed declarations and code are not supported in cc65");
|
||||||
while (CurTok.Tok != TOK_SEMI) {
|
while (CurTok.Tok != TOK_SEMI) {
|
||||||
Declaration Decl;
|
Declarator Decl;
|
||||||
|
|
||||||
/* Parse one declaration */
|
/* Parse one declaration */
|
||||||
ParseDecl (&Spec, &Decl, DM_ACCEPT_IDENT);
|
ParseDecl (&Spec, &Decl, DM_ACCEPT_IDENT);
|
||||||
|
@ -602,7 +602,7 @@ static unsigned ParseStructInit (Type* T, int* Braces, int AllowFlexibleMembers)
|
|||||||
|
|
||||||
/* Standard member. We should never have stuff from a
|
/* Standard member. We should never have stuff from a
|
||||||
** bit-field left because an anonymous member was added
|
** bit-field left because an anonymous member was added
|
||||||
** for padding by ParseStructDecl.
|
** for padding by ParseStructSpec.
|
||||||
*/
|
*/
|
||||||
CHECK (SI.ValBits == 0);
|
CHECK (SI.ValBits == 0);
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ static void AllocStorage (unsigned DataLabel, void (*UseSeg) (), unsigned Size)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ParseRegisterDecl (Declaration* Decl, int Reg)
|
static void ParseRegisterDecl (Declarator* Decl, int Reg)
|
||||||
/* Parse the declaration of a register variable. Reg is the offset of the
|
/* Parse the declarator of a register variable. Reg is the offset of the
|
||||||
** variable in the register bank.
|
** variable in the register bank.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
@ -186,8 +186,8 @@ static void ParseRegisterDecl (Declaration* Decl, int Reg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ParseAutoDecl (Declaration* Decl)
|
static void ParseAutoDecl (Declarator* Decl)
|
||||||
/* Parse the declaration of an auto variable. */
|
/* Parse the declarator of an auto variable. */
|
||||||
{
|
{
|
||||||
unsigned Flags;
|
unsigned Flags;
|
||||||
SymEntry* Sym;
|
SymEntry* Sym;
|
||||||
@ -382,8 +382,8 @@ static void ParseAutoDecl (Declaration* Decl)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ParseStaticDecl (Declaration* Decl)
|
static void ParseStaticDecl (Declarator* Decl)
|
||||||
/* Parse the declaration of a static variable. */
|
/* Parse the declarator of a static variable. */
|
||||||
{
|
{
|
||||||
unsigned Size;
|
unsigned Size;
|
||||||
|
|
||||||
@ -441,12 +441,12 @@ static void ParseStaticDecl (Declaration* Decl)
|
|||||||
|
|
||||||
|
|
||||||
static void ParseOneDecl (const DeclSpec* Spec)
|
static void ParseOneDecl (const DeclSpec* Spec)
|
||||||
/* Parse one variable declaration */
|
/* Parse one variable declarator. */
|
||||||
{
|
{
|
||||||
Declaration Decl; /* Declaration data structure */
|
Declarator Decl; /* Declarator data structure */
|
||||||
|
|
||||||
|
|
||||||
/* Read the declaration */
|
/* Read the declarator */
|
||||||
ParseDecl (Spec, &Decl, DM_NEED_IDENT);
|
ParseDecl (Spec, &Decl, DM_NEED_IDENT);
|
||||||
|
|
||||||
/* Check if there are any non-extern storage classes set for function
|
/* Check if there are any non-extern storage classes set for function
|
||||||
|
@ -230,8 +230,8 @@ const DeclAttr* SymGetAttr (const SymEntry* Sym, DeclAttrType AttrType)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SymUseAttr (SymEntry* Sym, struct Declaration* D)
|
void SymUseAttr (SymEntry* Sym, struct Declarator* D)
|
||||||
/* Use the attributes from the declaration for this symbol */
|
/* Use the attributes from the declarator for this symbol */
|
||||||
{
|
{
|
||||||
/* We cannot specify attributes twice */
|
/* We cannot specify attributes twice */
|
||||||
if ((Sym->Flags & SC_HAVEATTR) != 0) {
|
if ((Sym->Flags & SC_HAVEATTR) != 0) {
|
||||||
|
@ -298,8 +298,8 @@ INLINE int SymHasAttr (const SymEntry* Sym, DeclAttrType A)
|
|||||||
# define SymHasAttr(Sym, A) (SymGetAttr (Sym, A) != 0)
|
# define SymHasAttr(Sym, A) (SymGetAttr (Sym, A) != 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SymUseAttr (SymEntry* Sym, struct Declaration* D);
|
void SymUseAttr (SymEntry* Sym, struct Declarator* D);
|
||||||
/* Use the attributes from the declaration for this symbol */
|
/* Use the attributes from the declarator for this symbol */
|
||||||
|
|
||||||
void SymSetAsmName (SymEntry* Sym);
|
void SymSetAsmName (SymEntry* Sym);
|
||||||
/* Set the assembler name for an external symbol from the name of the symbol.
|
/* Set the assembler name for an external symbol from the name of the symbol.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user