X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=parser.c;h=37190b014b901a84f7f75dd8c718dd5d49f80773;hb=c10b6aa243f6a36e53fb4aef63da3258b369bddb;hp=09930b025df14de6e72a39736917bc258c2d6257;hpb=1a47a352dc074585e56b11a6e1e693e8ece6b5be;p=cparser diff --git a/parser.c b/parser.c index 09930b0..37190b0 100644 --- a/parser.c +++ b/parser.c @@ -1833,11 +1833,10 @@ static void descend_into_subtype(type_path_t *path) top->type = top_type; if (is_type_compound(top_type)) { - compound_t *compound = top_type->compound.compound; - entity_t *entry = compound->members.entities; + compound_t *const compound = top_type->compound.compound; + entity_t *const entry = skip_unnamed_bitfields(compound->members.entities); if (entry != NULL) { - assert(entry->kind == ENTITY_COMPOUND_MEMBER); top->v.compound_entry = &entry->declaration; path->top_type = entry->declaration.type; } else { @@ -1977,7 +1976,7 @@ static void advance_current_object(type_path_t *path, size_t top_path_level) } else if (is_type_struct(type)) { declaration_t *entry = top->v.compound_entry; - entity_t *next_entity = entry->base.next; + entity_t *const next_entity = skip_unnamed_bitfields(entry->base.next); if (next_entity != NULL) { assert(is_declaration(next_entity)); entry = &next_entity->declaration; @@ -4105,8 +4104,15 @@ entity_t *record_entity(entity_t *entity, const bool is_definition) goto finish; } if (previous_entity->kind == ENTITY_TYPEDEF) { - /* TODO: C++ allows this for exactly the same type */ - errorf(pos, "redefinition of '%N' (declared %P)", entity, ppos); + type_t *const type = skip_typeref(entity->typedefe.type); + type_t *const prev_type + = skip_typeref(previous_entity->typedefe.type); + /* gcc extension redef in system headers is allowed */ + if ((!(c_mode & _CXX) && !pos->is_system_header) + || !types_compatible(type, prev_type)) { + errorf(pos, "redefinition of '%N' (declared %P)", + entity, ppos); + } goto finish; } @@ -4186,7 +4192,7 @@ warn_redundant_declaration: ; merge_in_attributes(decl, prev_decl->attributes); } else if (!is_definition && is_type_valid(prev_type) && - strcmp(ppos->input_name, "") != 0) { + !pos->is_system_header) { warningf(WARN_REDUNDANT_DECLS, pos, "redundant declaration for '%Y' (declared %P)", symbol, ppos); } } else if (current_function == NULL) {