Don't mix storage class bits with ctype->modifiers while parsing type
Keep storage class (and "is it inline") explicitly in decl_state; translate to modifiers only when we are done with parsing. That avoids the need to separate MOD_STORAGE bits while constructing the type (e.g. in alloc_indirect_symbol(), etc.). It also allows to get rid of MOD_FORCE for good - instead of passing it to typename() we pass an int * and let typename() tell whether we'd got a force-cast. Indication of force-cast never makes it into the modifier bits at all.
Signed-off-by Al Viro <[email protected]>
--- expression.c | 12 +++---- expression.h | 2 +- gdbhelpers | 3 -- parse.c | 107 ++++++++++++++++++++++++++++++++++++++++++---------------- symbol.h | 5 +-- 5 files changed, 86 insertions(+), 43 deletions(-)
expression.c +5 -7
@@ -118,7 +118,7 @@ static struct token *parse_type(struct token *token, struct expression **tree)struct symbol *sym; *tree =alloc_expression (token->pos,EXPR_TYPE ); (*tree)->flags = Int_const_expr;/* sic */ - token =typename (token, &sym,0 ); + token =typename (token, &sym,NULL );if (sym->ident)sparse_error (token->pos, "type expression should not include identifier "
@@ -167,7 +167,7 @@ static struct token *builtin_offsetof_expr(struct token *token,return expect (token,'(' ,"after __builtin_offset" ); token = token->next; - token =typename (token, &sym,0 ); + token =typename (token, &sym,NULL );if (sym->ident)sparse_error (token->pos, "type expression should not include identifier "
@@ -482,7 +482,7 @@ struct token *primary_expression(struct token *token, struct expression **tree)if (token->special =='[' &&lookup_type (token->next)) { expr =alloc_expression (token->pos,EXPR_TYPE ); expr->flags = Int_const_expr;/* sic */ - token =typename (token->next, &expr->symbol,0 ); + token =typename (token->next, &expr->symbol,NULL ); token =expect (token,']' ,"in type expression" );break ; }
@@ -602,7 +602,7 @@ static struct token *type_info_expression(struct token *token,if (!match_op (token,'(' ) || !lookup_type (token->next))return unary_expression (token, &expr->cast_expression); p = token; - token =typename (token->next, &expr->cast_type,0 ); + token =typename (token->next, &expr->cast_type,NULL );if (!match_op (token,')' )) {static const char * error[] = {
@@ -727,10 +727,8 @@ static struct token *cast_expression(struct token *token, struct expression **trstruct symbol *sym;int is_force; - token =typename (next, &sym,MOD_FORCE ); + token =typename (next, &sym, &is_force); cast->cast_type = sym; - is_force = sym->ctype.modifiers &MOD_FORCE ; - sym->ctype.modifiers &= ~MOD_FORCE ; token =expect (token,')' ,"at end of cast operator" );if (match_op (token,'{' )) {if (is_force)
expression.h +1 -1
@@ -193,7 +193,7 @@ static inline struct expression *alloc_const_expression(struct position pos, int }/* Type name parsing */ -struct token *typename (struct token *,struct symbol **,int ); +struct token *typename (struct token *,struct symbol **,int *);static inline int lookup_type (struct token *token) {
gdbhelpers +0 -3
@@ -158,9 +158,6 @@ define gdb_show_ctype if ($arg0->modifiers & MOD_USERTYPE) printf "MOD_USERTYPE " end - if ($arg0->modifiers & MOD_FORCE) - printf "MOD_FORCE " - end if ($arg0->modifiers & MOD_EXPLICITLY_SIGNED) printf "MOD_EXPLICITLY_SIGNED" end
parse.c +78 -29
267 lines not on this page · raw message
symbol.h +2 -3
@@ -92,8 +92,8 @@ struct ctype {struct decl_state {struct ctype ctype;struct ident **ident; -int prefer_abstract;struct symbol_op *mode; +unsigned char prefer_abstract, is_inline, storage_class; };struct symbol_op {
@@ -212,12 +212,11 @@ struct symbol {#define MOD_SAFE 0x8000000 // non-null/non-trapping pointer#define MOD_USERTYPE 0x10000000 -#define MOD_FORCE 0x20000000#define MOD_EXPLICITLY_SIGNED 0x40000000#define MOD_BITWISE 0x80000000#define MOD_NONLOCAL (MOD_EXTERN | MOD_TOPLEVEL) -#define MOD_STORAGE (MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN | MOD_INLINE | MOD_TOPLEVEL | MOD_FORCE) +#define MOD_STORAGE (MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN | MOD_INLINE | MOD_TOPLEVEL)#define MOD_SIGNEDNESS (MOD_SIGNED | MOD_UNSIGNED | MOD_EXPLICITLY_SIGNED)#define MOD_SPECIFIER (MOD_CHAR | MOD_SHORT | MOD_LONG | MOD_LONGLONG | MOD_SIGNEDNESS)#define MOD_SIZE (MOD_CHAR | MOD_SHORT | MOD_LONG | MOD_LONGLONG)
Signature · 1 line
1.5.6.5