| ... | ... | @@ -680,11 +680,10 @@ static AstNode *trans_type(Context *c, const Type *ty, const SourceLocation &sou |
| 680 | 680 | const ElaboratedType *elaborated_ty = static_cast<const ElaboratedType*>(ty); |
| 681 | 681 | switch (elaborated_ty->getKeyword()) { |
| 682 | 682 | case ETK_Struct: |
| 683 | | return trans_qual_type(c, elaborated_ty->getNamedType(), source_loc); |
| 684 | 683 | case ETK_Enum: |
| 684 | case ETK_Union: |
| 685 | 685 | return trans_qual_type(c, elaborated_ty->getNamedType(), source_loc); |
| 686 | 686 | case ETK_Interface: |
| 687 | | case ETK_Union: |
| 688 | 687 | case ETK_Class: |
| 689 | 688 | case ETK_Typename: |
| 690 | 689 | case ETK_None: |
| ... | ... | @@ -2946,15 +2945,24 @@ static AstNode *resolve_record_decl(Context *c, const RecordDecl *record_decl) { |
| 2946 | 2945 | |
| 2947 | 2946 | const char *raw_name = decl_name(record_decl); |
| 2948 | 2947 | |
| 2949 | | if (!record_decl->isStruct()) { |
| 2950 | | emit_warning(c, record_decl->getLocation(), "skipping record %s, not a struct", raw_name); |
| 2948 | const char *container_kind_name; |
| 2949 | ContainerKind container_kind; |
| 2950 | if (record_decl->isUnion()) { |
| 2951 | container_kind_name = "union"; |
| 2952 | container_kind = ContainerKindUnion; |
| 2953 | } else if (record_decl->isStruct()) { |
| 2954 | container_kind_name = "struct"; |
| 2955 | container_kind = ContainerKindStruct; |
| 2956 | } else { |
| 2957 | emit_warning(c, record_decl->getLocation(), "skipping record %s, not a struct or union", raw_name); |
| 2951 | 2958 | c->decl_table.put(record_decl->getCanonicalDecl(), nullptr); |
| 2952 | 2959 | return nullptr; |
| 2953 | 2960 | } |
| 2954 | 2961 | |
| 2955 | 2962 | bool is_anonymous = record_decl->isAnonymousStructOrUnion() || raw_name[0] == 0; |
| 2956 | 2963 | Buf *bare_name = is_anonymous ? nullptr : buf_create_from_str(raw_name); |
| 2957 | | Buf *full_type_name = (bare_name == nullptr) ? nullptr : buf_sprintf("struct_%s", buf_ptr(bare_name)); |
| 2964 | Buf *full_type_name = (bare_name == nullptr) ? |
| 2965 | nullptr : buf_sprintf("%s_%s", container_kind_name, buf_ptr(bare_name)); |
| 2958 | 2966 | |
| 2959 | 2967 | RecordDecl *record_def = record_decl->getDefinition(); |
| 2960 | 2968 | if (record_def == nullptr) { |
| ... | ... | @@ -2970,14 +2978,15 @@ static AstNode *resolve_record_decl(Context *c, const RecordDecl *record_decl) { |
| 2970 | 2978 | const FieldDecl *field_decl = *it; |
| 2971 | 2979 | |
| 2972 | 2980 | if (field_decl->isBitField()) { |
| 2973 | | emit_warning(c, field_decl->getLocation(), "struct %s demoted to opaque type - has bitfield", |
| 2981 | emit_warning(c, field_decl->getLocation(), "%s %s demoted to opaque type - has bitfield", |
| 2982 | container_kind_name, |
| 2974 | 2983 | is_anonymous ? "(anon)" : buf_ptr(bare_name)); |
| 2975 | 2984 | return demote_struct_to_opaque(c, record_decl, full_type_name, bare_name); |
| 2976 | 2985 | } |
| 2977 | 2986 | } |
| 2978 | 2987 | |
| 2979 | 2988 | AstNode *struct_node = trans_create_node(c, NodeTypeContainerDecl); |
| 2980 | | struct_node->data.container_decl.kind = ContainerKindStruct; |
| 2989 | struct_node->data.container_decl.kind = container_kind; |
| 2981 | 2990 | struct_node->data.container_decl.layout = ContainerLayoutExtern; |
| 2982 | 2991 | |
| 2983 | 2992 | // TODO handle attribute packed |
| ... | ... | @@ -3004,7 +3013,8 @@ static AstNode *resolve_record_decl(Context *c, const RecordDecl *record_decl) { |
| 3004 | 3013 | |
| 3005 | 3014 | if (field_node->data.struct_field.type == nullptr) { |
| 3006 | 3015 | emit_warning(c, field_decl->getLocation(), |
| 3007 | | "struct %s demoted to opaque type - unresolved type", |
| 3016 | "%s %s demoted to opaque type - unresolved type", |
| 3017 | container_kind_name, |
| 3008 | 3018 | is_anonymous ? "(anon)" : buf_ptr(bare_name)); |
| 3009 | 3019 | |
| 3010 | 3020 | return demote_struct_to_opaque(c, record_decl, full_type_name, bare_name); |