Print this page
11972 resync smatch

*** 31,40 **** --- 31,41 ---- #include "token.h" #include "parse.h" #include "symbol.h" #include "scope.h" #include "expression.h" + #include "evaluate.h" #include "target.h" /* * Secondary symbol list for stuff that needs to be output because it
*** 46,58 **** * If the symbol is an inline symbol, add it to the list of symbols to parse */ void access_symbol(struct symbol *sym) { if (sym->ctype.modifiers & MOD_INLINE) { ! if (!(sym->ctype.modifiers & MOD_ACCESSED)) { add_symbol(&translation_unit_used_list, sym); ! sym->ctype.modifiers |= MOD_ACCESSED; } } } struct symbol *lookup_symbol(struct ident *ident, enum namespace ns) --- 47,59 ---- * If the symbol is an inline symbol, add it to the list of symbols to parse */ void access_symbol(struct symbol *sym) { if (sym->ctype.modifiers & MOD_INLINE) { ! if (!sym->accessed) { add_symbol(&translation_unit_used_list, sym); ! sym->accessed = 1; } } } struct symbol *lookup_symbol(struct ident *ident, enum namespace ns)
*** 211,221 **** /* Check the base type */ base_type = examine_symbol_type(sym->ctype.base_type); if (!base_type || base_type->type == SYM_PTR) return base_type; ! sym->ctype.as |= base_type->ctype.as; sym->ctype.modifiers |= base_type->ctype.modifiers & MOD_PTRINHERIT; concat_ptr_list((struct ptr_list *)base_type->ctype.contexts, (struct ptr_list **)&sym->ctype.contexts); if (base_type->type == SYM_NODE) { base_type = base_type->ctype.base_type; --- 212,222 ---- /* Check the base type */ base_type = examine_symbol_type(sym->ctype.base_type); if (!base_type || base_type->type == SYM_PTR) return base_type; ! combine_address_space(sym->pos, &sym->ctype.as, base_type->ctype.as); sym->ctype.modifiers |= base_type->ctype.modifiers & MOD_PTRINHERIT; concat_ptr_list((struct ptr_list *)base_type->ctype.contexts, (struct ptr_list **)&sym->ctype.contexts); if (base_type->type == SYM_NODE) { base_type = base_type->ctype.base_type;
*** 275,285 **** /* * "typeof" will have to merge the types together */ void merge_type(struct symbol *sym, struct symbol *base_type) { ! sym->ctype.as |= base_type->ctype.as; sym->ctype.modifiers |= (base_type->ctype.modifiers & ~MOD_STORAGE); concat_ptr_list((struct ptr_list *)base_type->ctype.contexts, (struct ptr_list **)&sym->ctype.contexts); sym->ctype.base_type = base_type->ctype.base_type; if (sym->ctype.base_type->type == SYM_NODE) --- 276,286 ---- /* * "typeof" will have to merge the types together */ void merge_type(struct symbol *sym, struct symbol *base_type) { ! combine_address_space(sym->pos, &sym->ctype.as, base_type->ctype.as); sym->ctype.modifiers |= (base_type->ctype.modifiers & ~MOD_STORAGE); concat_ptr_list((struct ptr_list *)base_type->ctype.contexts, (struct ptr_list **)&sym->ctype.contexts); sym->ctype.base_type = base_type->ctype.base_type; if (sym->ctype.base_type->type == SYM_NODE)
*** 362,371 **** --- 363,389 ---- return sym->initializer; } while ((sym = sym->same_symbol) != NULL); return NULL; } + static unsigned int implicit_array_size(struct symbol *node, unsigned int count) + { + struct symbol *arr_ori = node->ctype.base_type; + struct symbol *arr_new = alloc_symbol(node->pos, SYM_ARRAY); + struct symbol *elem_type = arr_ori->ctype.base_type; + struct expression *size = alloc_const_expression(node->pos, count); + unsigned int bit_size = array_element_offset(elem_type->bit_size, count); + + *arr_new = *arr_ori; + arr_new->bit_size = bit_size; + arr_new->array_size = size; + node->array_size = size; + node->ctype.base_type = arr_new; + + return bit_size; + } + static struct symbol * examine_node_type(struct symbol *sym) { struct symbol *base_type = examine_base_type(sym); int bit_size; unsigned long alignment;
*** 391,401 **** if (initializer) { struct symbol *node_type = base_type->ctype.base_type; int count = count_array_initializer(node_type, initializer); if (node_type && node_type->bit_size >= 0) ! bit_size = array_element_offset(node_type->bit_size, count); } } sym->bit_size = bit_size; return sym; --- 409,419 ---- if (initializer) { struct symbol *node_type = base_type->ctype.base_type; int count = count_array_initializer(node_type, initializer); if (node_type && node_type->bit_size >= 0) ! bit_size = implicit_array_size(sym, count); } } sym->bit_size = bit_size; return sym;
*** 477,493 **** sym->type = SYM_NODE; sym->ctype.modifiers = mod; sym->ctype.base_type = base; return examine_node_type(sym); } ! break; } case SYM_PREPROCESSOR: sparse_error(sym->pos, "ctype on preprocessor command? (%s)", show_ident(sym->ident)); return NULL; case SYM_UNINITIALIZED: ! // sparse_error(sym->pos, "ctype on uninitialized symbol %p", sym); return NULL; case SYM_RESTRICT: examine_base_type(sym); return sym; case SYM_FOULED: --- 495,513 ---- sym->type = SYM_NODE; sym->ctype.modifiers = mod; sym->ctype.base_type = base; return examine_node_type(sym); } ! sym->type = SYM_NODE; ! sym->ctype.base_type = &bad_ctype; ! return sym; } case SYM_PREPROCESSOR: sparse_error(sym->pos, "ctype on preprocessor command? (%s)", show_ident(sym->ident)); return NULL; case SYM_UNINITIALIZED: ! // sparse_error(sym->pos, "ctype on uninitialized symbol '%s'", show_typename(sym)); return NULL; case SYM_RESTRICT: examine_base_type(sym); return sym; case SYM_FOULED:
*** 675,684 **** --- 695,712 ---- lllong_ctype, slllong_ctype, ulllong_ctype, float_ctype, double_ctype, ldouble_ctype, string_ctype, ptr_ctype, lazy_ptr_ctype, incomplete_ctype, label_ctype, bad_ctype, null_ctype; + struct symbol int_ptr_ctype, uint_ptr_ctype; + struct symbol long_ptr_ctype, ulong_ptr_ctype; + struct symbol llong_ptr_ctype, ullong_ptr_ctype; + struct symbol float32_ctype, float32x_ctype; + struct symbol float64_ctype, float64x_ctype; + struct symbol float128_ctype; + struct symbol const_void_ctype, const_char_ctype; + struct symbol const_ptr_ctype, const_string_ctype; struct symbol zero_int; #define __INIT_IDENT(str, res) { .len = sizeof(str)-1, .name = str, .reserved = res } #define __IDENT(n,str,res) \
*** 701,710 **** --- 729,742 ---- #ifdef __CHAR_UNSIGNED__ #define CHAR_SIGNEDNESS MOD_UNSIGNED #else #define CHAR_SIGNEDNESS MOD_SIGNED #endif + // For fix-sized types + static int bits_in_type32 = 32; + static int bits_in_type64 = 64; + static int bits_in_type128 = 128; #define MOD_ESIGNED (MOD_SIGNED | MOD_EXPLICITLY_SIGNED) #define MOD_LL (MOD_LONG | MOD_LONGLONG) #define MOD_LLL MOD_LONGLONGLONG static const struct ctype_declare {
*** 742,756 **** --- 774,805 ---- { &float_ctype, SYM_BASETYPE, 0, &bits_in_float, &max_fp_alignment, &fp_type }, { &double_ctype, SYM_BASETYPE, MOD_LONG, &bits_in_double, &max_fp_alignment, &fp_type }, { &ldouble_ctype, SYM_BASETYPE, MOD_LONG | MOD_LONGLONG, &bits_in_longdouble, &max_fp_alignment, &fp_type }, + { &float32_ctype, SYM_BASETYPE, 0, &bits_in_type32, &max_fp_alignment, &fp_type }, + { &float32x_ctype, SYM_BASETYPE, MOD_LONG, &bits_in_double, &max_fp_alignment, &fp_type }, + { &float64_ctype, SYM_BASETYPE, 0, &bits_in_type64, &max_fp_alignment, &fp_type }, + { &float64x_ctype, SYM_BASETYPE, MOD_LONG | MOD_LONGLONG, &bits_in_longdouble, &max_fp_alignment, &fp_type }, + { &float128_ctype, SYM_BASETYPE, 0, &bits_in_type128, &max_alignment, &fp_type }, + { &string_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &char_ctype }, { &ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, { &null_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, { &label_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, { &lazy_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &void_ctype }, + { &int_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &int_ctype }, + { &uint_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &uint_ctype }, + { &long_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &long_ctype }, + { &ulong_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &ulong_ctype }, + { &llong_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &llong_ctype }, + { &ullong_ptr_ctype,SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &ullong_ctype }, + + { &const_void_ctype, SYM_NODE, MOD_CONST, NULL, NULL, &void_ctype }, + { &const_char_ctype, SYM_NODE, MOD_CONST, &bits_in_char, &max_int_alignment, &char_ctype }, + { &const_ptr_ctype, SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &const_void_ctype }, + { &const_string_ctype,SYM_PTR, 0, &bits_in_pointer, &pointer_alignment, &const_char_ctype }, { NULL, } }; #undef MOD_LLL #undef MOD_LL #undef MOD_ESIGNED
*** 771,776 **** --- 820,831 ---- sym->bit_size = bit_size; sym->ctype.alignment = alignment; sym->ctype.base_type = ctype->base_type; sym->ctype.modifiers = ctype->modifiers; } + + // and now some adjustments + if (funsigned_char) { + char_ctype.ctype.modifiers |= MOD_UNSIGNED; + char_ctype.ctype.modifiers &= ~MOD_SIGNED; + } }