Lines Matching defs:sym

588 	struct symbol *sym = create_symbol(stream, kw->name, SYM_KEYWORD, ns);
589 sym->ident->keyword = 1;
590 sym->ident->reserved |= (ns == NS_TYPEDEF);
591 sym->ctype.modifiers = kw->mods;
592 sym->ctype.base_type = kw->type;
593 sym->op = kw->op;
607 struct symbol *sym = create_symbol(stream, name, SYM_KEYWORD,
609 if (!sym->op) {
610 sym->ident->keyword = 1;
611 sym->op = &ignore_attr_op;
656 static void fn_local_symbol(struct symbol *sym)
659 add_symbol(function_symbol_list, sym);
690 struct symbol *sym = alloc_symbol(pos, type);
692 sym->ctype.base_type = ctype->base_type;
693 sym->ctype.modifiers = ctype->modifiers;
695 ctype->base_type = sym;
697 return sym;
707 struct symbol *sym = lookup_symbol(token->ident, NS_LABEL);
708 if (!sym) {
709 sym = alloc_symbol(token->pos, SYM_LABEL);
710 bind_symbol(sym, token->ident, NS_LABEL);
712 sym->used = 1;
713 fn_local_symbol(sym);
715 return sym;
723 struct symbol *sym;
728 sym = lookup_symbol(token->ident, NS_STRUCT);
729 if (!sym ||
730 (is_outer_scope(sym->scope) &&
734 sym = alloc_symbol(token->pos, type);
735 bind_symbol(sym, token->ident, NS_STRUCT);
737 if (sym->type != type)
738 error_die(token->pos, "invalid tag applied to %s", show_typename (sym));
739 ctx->ctype.base_type = sym;
748 if (sym->symbol_list)
749 error_die(token->pos, "redefinition of %s", show_typename (sym));
750 sym->pos = *repos;
753 sym->examined = 0;
756 sym = alloc_symbol(token->pos, type);
757 set_current_scope(sym); // used by dissect
758 ctx->ctype.base_type = sym;
765 token = parse(token->next, sym);
767 attr.ctype.base_type = sym;
769 apply_ctype(token->pos, &sym->ctype, &attr.ctype);
770 sym->packed = attr.packed;
772 sym->endpos = token->pos;
777 static struct token *parse_struct_declaration(struct token *token, struct symbol *sym)
781 res = struct_declaration_list(token, &sym->symbol_list);
782 FOR_EACH_PTR(sym->symbol_list, field) {
795 static struct token *parse_union_declaration(struct token *token, struct symbol *sym)
797 return struct_declaration_list(token, &sym->symbol_list);
800 static struct token *struct_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
805 static struct token *union_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
892 struct symbol *sym;
894 FOR_EACH_PTR(list, sym) {
895 struct expression *expr = sym->initializer;
908 } END_FOR_EACH_PTR(sym);
924 struct symbol *sym;
949 sym = alloc_symbol(token->pos, SYM_NODE);
950 bind_symbol(sym, token->ident, NS_SYMBOL);
951 sym->ctype.modifiers &= ~MOD_ADDRESSABLE;
952 sym->initializer = expr;
953 sym->enum_member = 1;
954 sym->ctype.base_type = parent;
955 add_ptr_list(&parent->symbol_list, sym);
1002 sym->endpos = token->pos;
1039 static struct token *enum_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1050 static struct token *typeof_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1058 struct symbol *sym;
1059 token = typename(token->next, &sym, NULL);
1060 ctx->ctype.base_type = sym->ctype.base_type;
1061 apply_ctype(token->pos, &ctx->ctype, &sym->ctype);
1076 static struct token *autotype_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1327 static struct token *attribute_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1356 static struct token *storage_specifier(struct token *next, struct symbol *sym, struct decl_state *ctx)
1359 unsigned long class = sym->ctype.modifiers;
1374 static struct token *thread_specifier(struct token *next, struct symbol *sym, struct decl_state *ctx)
1393 static struct token *alignas_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1402 struct symbol *sym = NULL;
1403 token = typename(token->next, &sym, NULL);
1404 sym = examine_symbol_type(sym);
1405 alignment = sym->ctype.alignment;
1428 static struct token *generic_qualifier(struct token *next, struct symbol *sym, struct decl_state *ctx)
1430 apply_qualifier(&next->pos, &ctx->ctype, sym->ctype.modifiers);
1599 static struct token *abstract_array_declarator(struct token *token, struct symbol *sym)
1605 struct symbol *sym = lookup_keyword(token->ident, NS_TYPEDEF);
1606 if (!sym || !(sym->op->type & (KW_STATIC|KW_QUALIFIER)))
1608 if (has_static && (sym->op->type & KW_STATIC))
1610 has_static |= (sym->op->type & KW_STATIC);
1619 sym->array_size = expr;
1651 struct symbol *sym;
1655 sym = lookup_keyword(token->ident, NS_TYPEDEF);
1656 if (!sym || !sym->op)
1658 return sym->op->type & KW_ATTRIBUTE;
1942 static struct token *parameter_declaration(struct token *token, struct symbol *sym)
1947 ctx.ident = &sym->ident;
1951 sym->ctype = ctx.ctype;
1952 sym->ctype.modifiers |= decl_modifiers(&ctx);
1953 sym->endpos = token->pos;
1954 sym->forced_arg = ctx.forced;
1962 struct symbol *sym = alloc_symbol(token->pos, SYM_NODE);
1963 *p = sym;
1967 sym->ctype = ctx.ctype;
1968 sym->endpos = token->pos;
1973 warning(sym->pos, "storage class in typename (%s%s)",
1974 modifier_string(class), show_typename(sym));
2136 static struct statement *start_function(struct symbol *sym)
2139 struct statement *stmt = alloc_statement(sym->pos, STMT_COMPOUND);
2142 ret = alloc_symbol(sym->pos, SYM_NODE);
2143 ret->ctype = sym->ctype.base_type->ctype;
2151 current_fn = sym;
2156 static void end_function(struct symbol *sym)
2204 struct symbol *sym;
2211 sym = alloc_symbol(stmt->pos, SYM_NODE);
2212 add_symbol(&target->symbol_list, sym);
2213 sym->stmt = stmt;
2214 stmt->case_label = sym;
2215 fn_local_symbol(sym);
2229 static void validate_for_loop_decl(struct symbol *sym)
2231 unsigned long storage = sym->ctype.modifiers & MOD_STORAGE;
2234 const char *name = show_ident(sym->ident);
2235 sparse_error(sym->pos, "non-local var '%s' in for-loop initializer", name);
2236 sym->ctype.modifiers &= ~MOD_STORAGE;
2497 struct symbol *sym = alloc_symbol(token->pos, SYM_LABEL);
2499 bind_symbol_with_scope(sym, token->ident, NS_LABEL, block_scope);
2500 fn_local_symbol(sym);
2545 struct symbol *sym = alloc_symbol(token->pos, SYM_NODE);
2546 sym->ident = token->ident;
2548 sym->endpos = token->pos;
2549 sym->ctype.base_type = &incomplete_ctype;
2550 add_symbol(list, sym);
2565 struct symbol *sym;
2573 sym = alloc_symbol(token->pos, SYM_NODE);
2574 token = parameter_declaration(token, sym);
2575 if (sym->ctype.base_type == &void_ctype) {
2577 if (!*list && !sym->ident)
2581 add_symbol(list, sym);
2719 static void declare_argument(struct symbol *sym, struct symbol *fn)
2721 if (!sym->ident) {
2722 sparse_error(sym->pos, "no identifier for function argument");
2725 if (sym->ctype.base_type == &incomplete_ctype) {
2726 sym->ctype.base_type = &int_ctype;
2729 sparse_error(sym->pos, "missing type declaration for parameter '%s'",
2730 show_ident(sym->ident));
2733 bind_symbol(sym, sym->ident, NS_SYMBOL);