X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=type.c;h=bcc1b255b8466450f79e214a0c19a1c9433ac594;hb=cbfb5f3fbdbc786f6893a12dd636916278a2fd4e;hp=8ec249517f91b601186dd92ad1e7217eea88989f;hpb=34471c5dd819ab71185ae606181aaa8c61673e9b;p=cparser diff --git a/type.c b/type.c index 8ec2495..bcc1b25 100644 --- a/type.c +++ b/type.c @@ -46,7 +46,6 @@ void print_type_qualifiers(unsigned qualifiers) if(qualifiers & TYPE_QUALIFIER_CONST) fputs("const ", out); if(qualifiers & TYPE_QUALIFIER_VOLATILE) fputs("volatile ", out); if(qualifiers & TYPE_QUALIFIER_RESTRICT) fputs("restrict ", out); - if(qualifiers & TYPE_QUALIFIER_INLINE) fputs("inline ", out); } static @@ -462,6 +461,53 @@ bool is_type_scalar(const type_t *type) return is_type_arithmetic(type); } +bool is_type_incomplete(const type_t *type) +{ + switch(type->type) { + case TYPE_COMPOUND_STRUCT: + case TYPE_COMPOUND_UNION: { + const compound_type_t *compound_type + = (const compound_type_t*) type; + declaration_t *declaration = compound_type->declaration; + return !declaration->init.is_defined; + } + case TYPE_FUNCTION: + return true; + + case TYPE_ARRAY: + case TYPE_ATOMIC: + case TYPE_POINTER: + case TYPE_ENUM: + return false; + + case TYPE_TYPEDEF: + case TYPE_TYPEOF: + case TYPE_BUILTIN: + panic("is_type_incomplete called without typerefs skipped"); + case TYPE_INVALID: + break; + } + + panic("invalid type found"); +} + +bool types_compatible(const type_t *type1, const type_t *type2) +{ + (void) type1; + (void) type2; + return true; +} + +bool pointers_compatible(const type_t *type1, const type_t *type2) +{ + assert(type1->type == TYPE_POINTER); + assert(type2->type == TYPE_POINTER); + pointer_type_t *pointer_type1 = (pointer_type_t*) type1; + pointer_type_t *pointer_type2 = (pointer_type_t*) type2; + return types_compatible(pointer_type1->points_to, + pointer_type2->points_to); +} + type_t *skip_typeref(type_t *type) { while(1) {