Lines Matching refs:ctx

52 static struct token *handle_attributes(struct token *token, struct decl_state *ctx);
674 static void apply_modifiers(struct position pos, struct decl_state *ctx)
677 if (!ctx->mode)
679 ctype = ctx->mode->to_mode(ctx->ctype.base_type);
682 show_typename(ctx->ctype.base_type));
684 ctx->ctype.base_type = ctype;
719 struct token *token, struct decl_state *ctx,
739 ctx->ctype.base_type = sym;
758 ctx->ctype.base_type = sym;
761 ctx->ctype.base_type = &bad_ctype;
800 static struct token *struct_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
802 return struct_union_enum_specifier(SYM_STRUCT, token, ctx, parse_struct_declaration);
805 static struct token *union_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
807 return struct_union_enum_specifier(SYM_UNION, token, ctx, parse_union_declaration);
923 struct decl_state ctx = { };
927 next = handle_attributes(next, &ctx);
1039 static struct token *enum_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1041 struct token *ret = struct_union_enum_specifier(SYM_ENUM, token, ctx, parse_enum_declaration);
1042 struct ctype *ctype = &ctx->ctype.base_type->ctype;
1050 static struct token *typeof_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1060 ctx->ctype.base_type = sym->ctype.base_type;
1061 apply_ctype(token->pos, &ctx->ctype, &sym->ctype);
1071 ctx->ctype.base_type = typeof_sym;
1076 static struct token *autotype_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1078 ctx->ctype.base_type = &autotype_ctype;
1079 ctx->autotype = 1;
1083 static struct token *ignore_attribute(struct token *token, struct symbol *attr, struct decl_state *ctx)
1091 static struct token *attribute_packed(struct token *token, struct symbol *attr, struct decl_state *ctx)
1093 if (!ctx->ctype.alignment) {
1094 ctx->ctype.alignment = 1;
1095 ctx->packed = 1;
1100 static struct token *attribute_aligned(struct token *token, struct symbol *attr, struct decl_state *ctx)
1113 } else if (alignment > ctx->ctype.alignment)
1114 ctx->ctype.alignment = alignment;
1125 static void apply_qualifier(struct position *pos, struct ctype *ctx, unsigned long qual)
1127 apply_mod(pos, &ctx->modifiers, qual);
1130 static struct token *attribute_modifier(struct token *token, struct symbol *attr, struct decl_state *ctx)
1132 apply_mod(&token->pos, &ctx->ctype.modifiers, attr->ctype.modifiers);
1136 static struct token *attribute_function(struct token *token, struct symbol *attr, struct decl_state *ctx)
1138 apply_mod(&token->pos, &ctx->f_modifiers, attr->ctype.modifiers);
1142 static struct token *attribute_bitwise(struct token *token, struct symbol *attr, struct decl_state *ctx)
1145 attribute_modifier(token, attr, ctx);
1159 static struct token *attribute_address_space(struct token *token, struct symbol *attr, struct decl_state *ctx)
1185 if (ctx->ctype.as)
1188 show_as(ctx->ctype.as), show_as(as));
1189 ctx->ctype.as = as;
1253 static struct token *attribute_mode(struct token *token, struct symbol *attr, struct decl_state *ctx)
1259 ctx->mode = mode->op;
1269 static struct token *attribute_context(struct token *token, struct symbol *attr, struct decl_state *ctx)
1290 add_ptr_list(&ctx->ctype.contexts, context);
1294 static struct token *attribute_designated_init(struct token *token, struct symbol *attr, struct decl_state *ctx)
1296 if (ctx->ctype.base_type && ctx->ctype.base_type->type == SYM_STRUCT)
1297 ctx->ctype.base_type->designated_init = 1;
1303 static struct token *attribute_transparent_union(struct token *token, struct symbol *attr, struct decl_state *ctx)
1308 if (ctx->ctype.base_type && ctx->ctype.base_type->type == SYM_UNION)
1309 ctx->ctype.base_type->transparent_union = 1;
1327 static struct token *attribute_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1335 token = attr->op->attribute(token->next, attr, ctx);
1349 static unsigned long decl_modifiers(struct decl_state *ctx)
1351 unsigned long mods = ctx->ctype.modifiers & MOD_DECLARE;
1352 ctx->ctype.modifiers &= ~MOD_DECLARE;
1353 return ctx->storage_class | mods;
1356 static struct token *storage_specifier(struct token *next, struct symbol *sym, struct decl_state *ctx)
1358 int is_tls = ctx->ctype.modifiers & MOD_TLS;
1365 else if (!ctx->storage_class)
1366 ctx->storage_class = class;
1367 else if (ctx->storage_class == class)
1374 static struct token *thread_specifier(struct token *next, struct symbol *sym, struct decl_state *ctx)
1377 if (!(ctx->storage_class & ~(MOD_STATIC|MOD_EXTERN))) {
1378 apply_qualifier(&next->pos, &ctx->ctype, MOD_TLS);
1381 modifier_name(ctx->storage_class));
1387 static struct token *attribute_force(struct token *token, struct symbol *attr, struct decl_state *ctx)
1389 ctx->forced = 1;
1393 static struct token *alignas_specifier(struct token *token, struct symbol *sym, struct decl_state *ctx)
1423 if (alignment > ctx->ctype.alignment)
1424 ctx->ctype.alignment = 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);
1505 static struct token *handle_qualifiers(struct token *t, struct decl_state *ctx)
1515 t = s->op->declarator(t, s, ctx);
1520 static struct token *declaration_specifiers(struct token *token, struct decl_state *ctx)
1535 ctx->ctype.base_type = s->ctype.base_type;
1536 apply_ctype(token->pos, &ctx->ctype, &s->ctype);
1567 token = s->op->declarator(token, s, ctx);
1569 ctx->ctype.base_type = s->ctype.base_type;
1570 ctx->ctype.modifiers |= s->ctype.modifiers;
1578 ctx->ctype.base_type = base;
1581 if (ctx->ctype.modifiers & MOD_BITWISE) {
1583 ctx->ctype.modifiers &= ~MOD_BITWISE;
1584 if (!is_int_type(ctx->ctype.base_type)) {
1589 *type = *ctx->ctype.base_type;
1591 type->ctype.base_type = ctx->ctype.base_type;
1593 ctx->ctype.base_type = type;
1625 static struct token *declarator(struct token *token, struct decl_state *ctx);
1627 static struct token *handle_asm_name(struct token *token, struct decl_state *ctx)
1697 static struct token *handle_attributes(struct token *token, struct decl_state *ctx)
1700 token = attribute_specifier(token->next, NULL, ctx);
1773 static struct token *direct_declarator(struct token *token, struct decl_state *ctx)
1775 struct ctype *ctype = &ctx->ctype;
1777 struct ident **p = ctx->ident;
1779 if (ctx->ident && token_type(token) == TOKEN_IDENT) {
1780 *ctx->ident = token->ident;
1783 is_nested(token, &next, ctx->prefer_abstract)) {
1786 next = handle_attributes(token->next, ctx);
1787 token = declarator(next, ctx);
1795 enum kind kind = which_func(token, p, ctx->prefer_abstract);
1798 ctype->modifiers |= ctx->f_modifiers;
1820 static struct token *pointer(struct token *token, struct decl_state *ctx)
1824 ptr->ctype.modifiers = ctx->ctype.modifiers;
1825 ptr->ctype.base_type = ctx->ctype.base_type;
1826 ptr->ctype.as = ctx->ctype.as;
1827 ptr->ctype.contexts = ctx->ctype.contexts;
1828 ctx->ctype.modifiers = 0;
1829 ctx->ctype.base_type = ptr;
1830 ctx->ctype.as = NULL;
1831 ctx->ctype.contexts = NULL;
1832 ctx->ctype.alignment = 0;
1834 token = handle_qualifiers(token->next, ctx);
1835 ctx->ctype.base_type->endpos = token->pos;
1840 static struct token *declarator(struct token *token, struct decl_state *ctx)
1842 token = pointer(token, ctx);
1843 return direct_declarator(token, ctx);
1846 static struct token *handle_bitfield(struct token *token, struct decl_state *ctx)
1848 struct ctype *ctype = &ctx->ctype;
1865 if (width < 0 || width > INT_MAX || (*ctx->ident && width == 0)) {
1867 show_ident(*ctx->ident), width);
1869 } else if (*ctx->ident) {
1888 bitfield->ident = *ctx->ident;
1894 struct decl_state ctx = {.prefer_abstract = 0};
1898 token = declaration_specifiers(token, &ctx);
1899 mod = decl_modifiers(&ctx);
1900 saved = ctx.ctype;
1903 ctx.ident = &decl->ident;
1905 token = declarator(token, &ctx);
1907 token = handle_bitfield(token, &ctx);
1909 token = handle_attributes(token, &ctx);
1910 apply_modifiers(token->pos, &ctx);
1912 decl->ctype = ctx.ctype;
1919 ctx.ctype = saved;
1944 struct decl_state ctx = {.prefer_abstract = 1};
1946 token = declaration_specifiers(token, &ctx);
1947 ctx.ident = &sym->ident;
1948 token = declarator(token, &ctx);
1949 token = handle_attributes(token, &ctx);
1950 apply_modifiers(token->pos, &ctx);
1951 sym->ctype = ctx.ctype;
1952 sym->ctype.modifiers |= decl_modifiers(&ctx);
1954 sym->forced_arg = ctx.forced;
1960 struct decl_state ctx = {.prefer_abstract = 1};
1964 token = declaration_specifiers(token, &ctx);
1965 token = declarator(token, &ctx);
1966 apply_modifiers(token->pos, &ctx);
1967 sym->ctype = ctx.ctype;
1969 class = ctx.storage_class;
1971 *forced = ctx.forced;
2442 struct decl_state ctx = { };
2444 token = handle_attributes(token, &ctx);
2445 label->label_modifiers = ctx.ctype.modifiers;
2892 struct decl_state ctx = { .ident = &ident };
2906 token = declaration_specifiers(token, &ctx);
2907 mod = decl_modifiers(&ctx);
2911 apply_modifiers(token->pos, &ctx);
2915 saved = ctx.ctype;
2916 token = declarator(token, &ctx);
2917 token = handle_asm_name(token, &ctx);
2918 token = handle_attributes(token, &ctx);
2919 apply_modifiers(token->pos, &ctx);
2921 decl->ctype = ctx.ctype;
2932 is_typedef = ctx.storage_class == MOD_USERTYPE;
2967 decl->ctype.modifiers |= ctx.f_modifiers;
3016 if (ctx.autotype) {
3039 ctx.ctype = saved;
3040 token = handle_attributes(token, &ctx);
3041 token = declarator(token, &ctx);
3042 token = handle_asm_name(token, &ctx);
3043 token = handle_attributes(token, &ctx);
3044 apply_modifiers(token->pos, &ctx);
3045 decl->ctype = ctx.ctype;