Lines Matching defs:sym

51 static struct symbol *evaluate_symbol(struct symbol *sym);
81 struct symbol *sym = expr->symbol;
84 if (!sym) {
89 examine_symbol_type(sym);
91 base_type = get_base_type(sym);
98 addr->symbol = sym;
100 addr->ctype = &lazy_ptr_ctype; /* Lazy evaluation: we need to do a proper job if somebody does &sym */
108 expr->ctype = sym;
109 return sym;
114 struct symbol *sym = alloc_symbol(expr->pos, SYM_NODE);
121 sym->array_size = alloc_const_expression(expr->pos, length);
122 sym->bit_size = length * char_type->bit_size;
123 sym->ctype.alignment = 1;
124 sym->string = 1;
125 sym->ctype.modifiers = MOD_STATIC;
126 sym->ctype.base_type = array;
127 sym->initializer = initstr;
128 sym->examined = 1;
129 sym->evaluated = 1;
131 initstr->ctype = sym;
134 array->array_size = sym->array_size;
135 array->bit_size = sym->bit_size;
142 addr->symbol = sym;
149 expr->ctype = sym;
150 return sym;
1277 struct symbol *sym = alloc_symbol(ctype->pos, SYM_PTR);
1278 *sym = *ctype;
1279 sym->ctype.modifiers |= qual;
1280 ctype = sym;
1538 struct symbol *sym = expr->symbol;
1539 sym->ctype.modifiers |= MOD_ADDRESSABLE;
1545 struct symbol *sym;
1551 sym = expr->symbol;
1552 if (!sym)
1554 if (sym->type != SYM_NODE)
1556 sym->ctype.modifiers |= MOD_ASSIGNED;
1646 static struct symbol *convert_to_as_mod(struct symbol *sym, struct ident *as, int mod)
1649 mod |= sym->ctype.modifiers;
1650 if (sym->ctype.as != as || sym->ctype.modifiers != mod) {
1651 struct symbol *newsym = alloc_symbol(sym->pos, SYM_NODE);
1652 *newsym = *sym;
1655 sym = newsym;
1657 return sym;
1660 static struct symbol *create_pointer(struct expression *expr, struct symbol *sym, int degenerate)
1672 access_symbol(sym);
1673 if (sym->ctype.modifiers & MOD_REGISTER) {
1674 warning(expr->pos, "taking address of 'register' variable '%s'", show_ident(sym->ident));
1675 sym->ctype.modifiers &= ~MOD_REGISTER;
1677 if (sym->type == SYM_NODE) {
1678 combine_address_space(sym->pos, &ptr->ctype.as, sym->ctype.as);
1679 ptr->ctype.modifiers |= sym->ctype.modifiers & MOD_PTRINHERIT;
1680 sym = sym->ctype.base_type;
1682 if (degenerate && sym->type == SYM_ARRAY) {
1683 combine_address_space(sym->pos, &ptr->ctype.as, sym->ctype.as);
1684 ptr->ctype.modifiers |= sym->ctype.modifiers & MOD_PTRINHERIT;
1685 sym = sym->ctype.base_type;
1687 ptr->ctype.base_type = sym;
2006 struct symbol *sym = (struct symbol *) list->list[i];
2007 if (sym->ident) {
2008 if (sym->ident != ident)
2010 *offset = sym->offset;
2011 return sym;
2013 struct symbol *ctype = sym->ctype.base_type;
2022 *offset += sym->offset;
2180 struct symbol *sym = expr->cast_type;
2181 if (!sym) {
2182 sym = evaluate_expression(expr->cast_expression);
2183 if (!sym)
2189 if (is_restricted_type(sym)) {
2190 if (sym->bit_size < bits_in_int && is_promoted(expr))
2191 sym = &int_ctype;
2192 } else if (is_fouled_type(sym)) {
2193 sym = &int_ctype;
2196 examine_symbol_type(sym);
2197 if (is_bitfield_type(sym)) {
2201 return sym;
2954 struct symbol *sym = expr->cast_type;
2956 sym->initializer = source;
2957 evaluate_symbol(sym);
2960 addr->symbol = sym;
2961 if (sym->ctype.modifiers & MOD_TOPLEVEL)
2967 expr->ctype = sym;
2968 return sym;
3161 struct symbol *ctype, *sym;
3167 sym = ctype = fn->ctype;
3180 show_ident(sym->ident));
3189 if (sym->type == SYM_NODE && fn->type == EXPR_PREOP &&
3190 sym->op && sym->op->args) {
3191 if (!sym->op->args(expr))
3201 show_ident(sym->ident));
3207 show_ident(sym->ident));
3210 if (sym->type == SYM_NODE) {
3488 void check_duplicates(struct symbol *sym)
3491 struct symbol *next = sym;
3492 int initialized = sym->initializer != NULL;
3498 sparse_error(sym->pos, "symbol '%s' has multiple initializers (originally initialized at %s:%d)",
3499 show_ident(sym->ident),
3505 typediff = type_difference(&sym->ctype, &next->ctype, 0, 0);
3507 sparse_error(sym->pos, "symbol '%s' redeclared with different type (%s):",
3508 show_ident(sym->ident), typediff);
3509 info(sym->pos, " %s", show_typename(sym));
3516 unsigned long mod = sym->ctype.modifiers;
3523 if (sym->ident == &main_ident)
3525 warning(sym->pos, "symbol '%s' was not declared. Should it be static?", show_ident(sym->ident));
3529 static struct symbol *evaluate_symbol(struct symbol *sym)
3533 if (!sym)
3534 return sym;
3535 if (sym->evaluated)
3536 return sym;
3537 sym->evaluated = 1;
3539 sym = examine_symbol_type(sym);
3540 base_type = get_base_type(sym);
3545 if (sym->initializer)
3546 evaluate_initializer(sym, &sym->initializer);
3552 if (sym->definition && sym->definition != sym)
3553 return evaluate_symbol(sym->definition);
3555 current_fn = sym;
3559 uninline(sym);
3571 struct symbol *sym;
3573 FOR_EACH_PTR(list, sym) {
3575 evaluate_symbol(sym);
3576 check_duplicates(sym);
3577 } END_FOR_EACH_PTR(sym);
3741 struct symbol *sym;
3790 FOR_EACH_PTR(stmt->asm_labels, sym) {
3791 if (!sym || sym->type != SYM_LABEL) {
3795 } END_FOR_EACH_PTR(sym);
3855 struct symbol *sym;
3867 FOR_EACH_PTR(stmt->switch_case->symbol_list, sym) {
3868 struct statement *case_stmt = sym->stmt;
3871 } END_FOR_EACH_PTR(sym);