enum cdump_type_kind kind,
const char *name)
{
- struct cdump_map *m;
+ cdump_map_t *m = (void *)0x1L; /* Shouldn't be used */
struct cdump_type *t;
switch (kind) {
return true;
}
+/* __attribute__((...)) */
+static bool tok_ignore_attribute(struct parse_state *ps)
+{
+ if (!tok_take_if(&ps->toks, "__attribute__"))
+ return true;
+
+ if (!tok_take_if(&ps->toks, "(") || !tok_take_if(&ps->toks, "(")) {
+ complain(ps, "Expected (( after __attribute__");
+ return false;
+ }
+
+ if (!tok_take_expr(ps, ")")) {
+ complain(ps, "Expected expression after __attribute__((");
+ return false;
+ }
+ if (!tok_take_if(&ps->toks, ")")) {
+ complain(ps, "Expected )) __attribute__((");
+ return false;
+ }
+ return true;
+}
+
/* struct|union ... */
static bool tok_take_conglom(struct parse_state *ps,
enum cdump_type_kind conglom_kind)
if (!tok_maybe_take_cdump_note(e, ps, &e->note))
return false;
+ if (!tok_ignore_attribute(ps))
+ return false;
+
if (!tok_take_if(&ps->toks, "{")) {
complain(ps, "Expected { for struct/union");
return false;
const struct token *quals;
unsigned int num_quals = 0;
+ if (!tok_ignore_attribute(ps))
+ return false;
+
/* Anything can have these prepended. */
quals = ps->toks;
while (tok_take_if(&ps->toks, "const")
while (tok_take_if(&ps->toks, "*"))
m->type = ptr_of(ps, m->type);
+ if (!tok_ignore_attribute(ps))
+ return false;
+
m->name = tok_take_ident(e, &ps->toks);
if (!m->name) {
complain(ps, "Expected name for member");
if (!tok_maybe_take_cdump_note(e->u.members,
ps, &m->note))
return false;
+
+ if (!tok_ignore_attribute(ps))
+ return false;
} while (tok_take_if(&ps->toks, ","));
if (!tok_take_if(&ps->toks, ";")) {
}
}
- if (tok_take_if(&ps->toks, "}") && tok_take_if(&ps->toks, ";"))
- return true;
- complain(ps, "Expected }; at end of struct/union");
- return false;
+ if (!tok_take_if(&ps->toks, "}")) {
+ complain(ps, "Expected } at end of struct/union");
+ return false;
+ }
+
+ if (!tok_ignore_attribute(ps))
+ return false;
+
+ if (!tok_take_if(&ps->toks, ";")) {
+ complain(ps, "Expected ; at end of struct/union");
+ return false;
+ }
+ return true;
}
/* enum ... */
if (!tok_maybe_take_cdump_note(e, ps, &e->note))
return false;
+ if (!tok_ignore_attribute(ps))
+ return false;
+
if (!tok_take_if(&ps->toks, "{")) {
complain(ps, "Expected { after enum name");
return false;
v->value = NULL;
} while (tok_take_if(&ps->toks, ","));
- if (tok_take_if(&ps->toks, "}") && tok_take_if(&ps->toks, ";"))
- return true;
+ if (!tok_take_if(&ps->toks, "}")) {
+ complain(ps, "Expected } at end of enum");
+ return false;
+ }
- complain(ps, "Expected }; at end of enum");
- return false;
+ if (!tok_ignore_attribute(ps))
+ return false;
+
+ if (!tok_take_if(&ps->toks, ";")) {
+ complain(ps, "Expected ; at end of enum");
+ return false;
+ }
+ return true;
}
static bool gather_undefines(const char *name,
struct cdump_type *t,
- struct cdump_map *undefs)
+ cdump_map_t *undefs)
{
if (!type_defined(t))
strmap_add(undefs, name, t);
static bool remove_from_map(const char *name,
struct cdump_type *t,
- struct cdump_map *map)
+ cdump_map_t *map)
{
strmap_del(map, name, NULL);
return true;
}
-static void remove_undefined(struct cdump_map *map)
+static void remove_undefined(cdump_map_t *map)
{
- struct cdump_map undefs;
+ cdump_map_t undefs;
/* We can't delete inside iterator, so gather all the undefs
* then remove them. */
toks = ps.toks = tokenize(ps.defs, code);
while (tok_peek(&ps.toks)) {
+ if (!tok_ignore_attribute(&ps))
+ goto fail;
if (tok_take_if(&ps.toks, "struct")) {
if (!tok_take_conglom(&ps, CDUMP_STRUCT))
goto fail;