[qfcc] Use a union to manage specifier bits

Having to remember to copy yet another specifier bit was getting
tedious, so use a union of a struct with the bitfields and an unsigned
int to access them in parallel. Makes for a tidier spec_merge, and one
less headache.
This commit is contained in:
Bill Currie 2022-02-05 18:45:54 +09:00
parent 078f36a871
commit f153e87daa
2 changed files with 16 additions and 17 deletions

View File

@ -89,6 +89,8 @@ typedef struct {
struct param_s *params;
struct symbol_s *sym; ///< for dealing with "int id" etc
storage_class_t storage;
union {
struct {
unsigned multi_type:1;
unsigned multi_store:1;
unsigned is_signed:1;
@ -99,6 +101,9 @@ typedef struct {
unsigned is_overload:1;
unsigned nosave:1;
unsigned no_va_list:1;
};
unsigned spec_bits;
};
} specifier_t;
#define EV_TYPE(type) extern type_t type_##type;

View File

@ -290,13 +290,7 @@ spec_merge (specifier_t spec, specifier_t new)
}
}
spec.sym = new.sym;
spec.is_signed |= new.is_signed;
spec.is_unsigned |= new.is_unsigned;
spec.is_short |= new.is_short;
spec.is_long |= new.is_long;
spec.is_overload |= new.is_overload;
spec.nosave |= new.nosave;
spec.no_va_list |= new.no_va_list;
spec.spec_bits |= new.spec_bits;
return spec;
}