7 * We can represent type specifiers as a bitmap, which gives us a finite
8 * list of acceptable bitmap values according to the C standard. However,
9 * the "long" specifier is allowed to occur more than once, but only at most
10 * 2 times. Treat it as a special case, assigning an unused bit to represent
13 #define CDECL_TYPE_LLONG 31
15 static unsigned long add_typespec(unsigned long map, struct cdecl_declspec *s)
17 if (s->type >= CDECL_TYPE_LLONG) {
18 fprintf(stderr, "invalid type specifier\n");
22 if (s->type == CDECL_TYPE_LONG) {
23 if (map & (1ul<<CDECL_TYPE_LLONG)) {
24 fprintf(stderr, "too many long specifiers\n");
26 } else if (map & (1ul<<CDECL_TYPE_LONG)) {
27 return map | (1ul<<CDECL_TYPE_LLONG);
31 if (map & (1ul<<s->type)) {
32 fprintf(stderr, "duplicate type specifier\n");
36 return map | (1ul<<s->type);
39 bool cdecl__typemap_is_valid(unsigned long map)
42 # include "validtypes.h"
49 unsigned long cdecl__build_typemap(struct cdecl_declspec *s)
51 unsigned long map = 0;
53 for (struct cdecl_declspec *c = s; c; c = c->next) {
54 if (cdecl_spec_kind(c) != CDECL_SPEC_TYPE)
57 map = add_typespec(map, c);