diff --git a/i386-gen.c b/i386-gen.c index 36a246ed..018165bf 100644 --- a/i386-gen.c +++ b/i386-gen.c @@ -307,7 +307,7 @@ ST_FUNC void load(int r, SValue *sv) fr = sv->r; ft = sv->type.t & ~VT_DEFSIGN; fc = sv->c.i; - ft &= ~(VT_VOLATILE | VT_CONSTANT); + ft &= ~VT_QUAL; v = fr & VT_VALMASK; #if defined CONFIG_TCC_PIC diff --git a/tcc.h b/tcc.h index ce9b5189..96e03198 100644 --- a/tcc.h +++ b/tcc.h @@ -1063,6 +1063,7 @@ struct filespec { #define VT_BITFIELD 0x0080 /* bitfield modifier */ #define VT_CONSTANT 0x0100 /* const modifier */ #define VT_VOLATILE 0x0200 /* volatile modifier */ +#define VT_QUAL (VT_CONSTANT | VT_VOLATILE) #define VT_VLA 0x0400 /* VLA type (also has VT_PTR and VT_ARRAY) */ #define VT_LONG 0x0800 /* long type (also has VT_INT rsp. VT_LLONG) */ diff --git a/tccdbg.c b/tccdbg.c index 67e85643..b0e94092 100644 --- a/tccdbg.c +++ b/tccdbg.c @@ -1787,7 +1787,7 @@ static int stabs_struct_find(TCCState *s1, Sym *t, int *p_id) static int remove_type_info(int type) { - type &= ~(VT_STORAGE | VT_CONSTANT | VT_VOLATILE | VT_VLA); + type &= ~(VT_STORAGE | VT_QUAL | VT_VLA); if ((type & VT_BTYPE) != VT_BYTE) type &= ~VT_DEFSIGN; if (!(type & VT_BITFIELD) && (type & VT_STRUCT_MASK) > VT_ENUM) @@ -2112,7 +2112,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) dwarf_data4(dwarf_info_section, sub_type - dwarf_info.start); dwarf_uleb128(dwarf_info_section, t->type.ref->c - 1); s = t->type.ref; - type = s->type.t & ~(VT_STORAGE | VT_CONSTANT | VT_VOLATILE); + type = s->type.t & ~(VT_STORAGE | VT_QUAL); if (type != (VT_PTR | VT_ARRAY)) break; t = s; diff --git a/tccgen.c b/tccgen.c index 4364ede4..23116d00 100644 --- a/tccgen.c +++ b/tccgen.c @@ -2822,7 +2822,7 @@ static inline int is_null_pointer(SValue *p) ((p->type.t & VT_BTYPE) == VT_PTR && (PTR_SIZE == 4 ? (uint32_t)p->c.i == 0 : p->c.i == 0) && ((pointed_type(&p->type)->t & VT_BTYPE) == VT_VOID) && - 0 == (pointed_type(&p->type)->t & (VT_CONSTANT | VT_VOLATILE)) + 0 == (pointed_type(&p->type)->t & VT_QUAL) ); } @@ -2871,8 +2871,8 @@ static int compare_types(CType *type1, CType *type2, int unqualified) t2 = type2->t & VT_TYPE; if (unqualified) { /* strip qualifiers before comparing */ - t1 &= ~(VT_CONSTANT | VT_VOLATILE); - t2 &= ~(VT_CONSTANT | VT_VOLATILE); + t1 &= ~VT_QUAL; + t2 &= ~VT_QUAL; } /* Default Vs explicit signedness only matters for char */ @@ -3490,7 +3490,7 @@ error: } done: vtop->type = *type; - vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY | VT_TLS ); + vtop->type.t &= ~ ( VT_QUAL | VT_ARRAY | VT_TLS ); } /* return type size as known at compile time. Put alignment at 'a' */ @@ -3573,7 +3573,7 @@ static int type_qualifiers(CType *type) { while (type->t & VT_ARRAY) type = pointed_type(type); - return type->t & (VT_CONSTANT | VT_VOLATILE); + return type->t & VT_QUAL; } /* modify type so that its it is a pointer to type. */ @@ -3641,8 +3641,7 @@ static void verify_assign_cast(CType *dt) if (is_compatible_types(type1, type2)) break; for (qualwarn = lvl = 0;; ++lvl) { - if (((type2->t & VT_CONSTANT) && !(type1->t & VT_CONSTANT)) || - ((type2->t & VT_VOLATILE) && !(type1->t & VT_VOLATILE))) + if ((type2->t & ~type1->t) & VT_QUAL) qualwarn = 1; dbt = type1->t & (VT_BTYPE|VT_LONG); sbt = type2->t & (VT_BTYPE|VT_LONG); @@ -4969,7 +4968,7 @@ static int parse_btype(CType *type, AttributeDef *ad, int ignore_label) } t &= ~(VT_BTYPE|VT_LONG); - u = t & ~(VT_CONSTANT | VT_VOLATILE), t ^= u; + u = t & ~VT_QUAL, t ^= u; type->t = (s->type.t & ~VT_TYPEDEF) | u; type->ref = s->type.ref; if (t) @@ -5016,7 +5015,7 @@ static inline void convert_parameter_type(CType *pt) /* apply the conversions required for an expression value */ static inline void convert_expression_type(CType *pt) { - pt->t &= ~(VT_CONSTANT | VT_VOLATILE); + pt->t &= ~VT_QUAL; convert_parameter_type(pt); } @@ -5121,7 +5120,7 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td) skip(')'); /* A function return value has the unqualified version of its declared type. */ - type->t &= ~(VT_CONSTANT | VT_VOLATILE); + type->t &= ~VT_QUAL; /* some ancient pre-K&R C allows a function to return an array and the array brackets to be put after the arguments, such that "int c()[]" means something like "int[] c()" */ @@ -6197,7 +6196,7 @@ special_math_val: /* field */ if (tok == TOK_ARROW) indir(); - qualifiers = vtop->type.t & (VT_CONSTANT | VT_VOLATILE); + qualifiers = vtop->type.t & VT_QUAL; test_lvalue(); /* expect pointer on structure */ next(); diff --git a/x86_64-gen.c b/x86_64-gen.c index ffa4cbc8..c62c8a0c 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -377,7 +377,7 @@ void load(int r, SValue *sv) SValue v1; fr = sv->r; - ft = sv->type.t & ~(VT_DEFSIGN|VT_VOLATILE|VT_CONSTANT); + ft = sv->type.t & ~(VT_DEFSIGN|VT_QUAL); fc = sv->c.i; if (fc != sv->c.i && (fr & VT_SYM))