summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndreas Fried <andreas.fried@kit.edu>2019-07-29 21:41:17 +0200
committerAndreas Fried <andreas.fried@kit.edu>2019-07-29 21:41:17 +0200
commit53bdf665a81f275bae9df686bfe70fd046df2866 (patch)
treea8165ae2725cd5ff86e913c03a8f577bc2550062
parent7703641da4bc8291f811a6b4c0f1911b126fe44a (diff)
Simplify find_create_select by using find_compound_entry.
-rw-r--r--src/parser/parser.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/parser/parser.c b/src/parser/parser.c
index ae8752d..63b55bb 100644
--- a/src/parser/parser.c
+++ b/src/parser/parser.c
@@ -5423,32 +5423,21 @@ static expression_t *find_create_select(const position_t *pos,
type_qualifiers_t qualifiers,
compound_t *compound, symbol_t *symbol)
{
- for (entity_t *iter = compound->members.first_entity; iter != NULL;
- iter = iter->base.next) {
- if (iter->kind != ENTITY_COMPOUND_MEMBER)
- continue;
-
- symbol_t *iter_symbol = iter->base.symbol;
- if (iter_symbol == NULL) {
- type_t *type = skip_typeref(iter->declaration.type);
- if (!is_type_compound(type))
- continue;
-
- compound_t *sub_compound = type->compound.compound;
- if (find_compound_entry(sub_compound, symbol) == NULL)
- continue;
+ expression_t *select = addr;
- expression_t *sub_addr = create_select(pos, addr, qualifiers, iter);
- sub_addr->base.implicit = true;
- return find_create_select(pos, sub_addr, qualifiers, sub_compound,
- symbol);
+ for (;;) {
+ entity_t *member = find_compound_entry(compound, symbol);
+ if (!member) {
+ return NULL;
}
-
- if (iter_symbol == symbol)
- return create_select(pos, addr, qualifiers, iter);
+ assert(member->kind == ENTITY_COMPOUND_MEMBER);
+ select = create_select(pos, select, qualifiers, member);
+ type_t *member_type = skip_typeref(member->declaration.type);
+ if (!is_type_compound(member_type) || member->base.symbol) {
+ return select;
+ }
+ compound = member_type->compound.compound;
}
-
- return NULL;
}
static void parse_bitfield_member(entity_t *entity)