decl *decl_new_ty_sp(type *ty, char *sp) { decl *d = decl_new(); d->ref = ty; d->spel = sp; return d; }
void fold_expr_sizeof(expr *e, symtable *stab) { if(!e->expr->expr_is_sizeof) fold_expr(e->expr, stab); e->tree_type = decl_new(); e->tree_type->type->primitive = type_int; }
void fold_expr_val(expr *e, symtable *stab) { (void)e; (void)stab; eof_where = &e->where; e->tree_type = decl_new(); e->tree_type->type->primitive = type_int; eof_where = NULL; }
static decl *compound_lit_decl(type *t, decl_init *init) { decl *d = decl_new(); d->ref = t; d->bits.var.init.dinit = init; return d; }
static void check_implicit_funcall(expr *e, symtable *stab, char **const psp) { struct symtab_entry ent; funcargs *args; decl *df, *owning_func; type *func_ty; if(e->expr->in_parens || !expr_kind(e->expr, identifier) /* not folded yet, hence no 'e->expr->bits.ident.type != IDENT_NORM' */ /* get the spel that parse stashes in the identifier expr: */ || !((*psp) = e->expr->bits.ident.bits.ident.spel)) { return; } /* check for implicit function */ if(symtab_search(stab, *psp, NULL, &ent) && ent.type == SYMTAB_ENT_DECL) { e->expr->bits.ident.bits.ident.sym = ent.bits.decl->sym; return; } args = funcargs_new(); /* set up the funcargs as if it's "x()" - i.e. any args */ funcargs_empty(args); func_ty = type_func_of( type_nav_btype(cc1_type_nav, type_int), args, symtab_new(stab, &e->where) /*new symtable for args*/); cc1_warn_at(&e->expr->where, implicit_func, "implicit declaration of function \"%s\"", *psp); df = decl_new(); memcpy_safe(&df->where, &e->where); df->ref = func_ty; df->spel = e->expr->bits.ident.bits.ident.spel; df->flags |= DECL_FLAGS_IMPLICIT; fold_decl(df, stab); /* update calling conv, for e.g. */ df->sym->type = sym_global; e->expr->bits.ident.bits.ident.sym = df->sym; e->expr->tree_type = func_ty; owning_func = symtab_func(stab); if(owning_func) symtab_insert_before(symtab_root(stab), owning_func, df); else symtab_add_to_scope(symtab_root(stab), df); /* function call at global scope */ }