X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=type.c;h=a35aa4477c3e46087f99107fb39d05b76fd4b423;hb=6c0cf065657863296355786c99aac830b85e2d9b;hp=a8705a4cc458258da28af4887b9925214d6e451a;hpb=d45cfc65d0ddf2bdcd05ea39e08f2890e5522d58;p=cparser diff --git a/type.c b/type.c index a8705a4..a35aa44 100644 --- a/type.c +++ b/type.c @@ -435,7 +435,7 @@ static void print_array_type_post(const array_type_t *type) static void print_bitfield_type_post(const bitfield_type_t *type) { fputs(" : ", out); - print_expression(type->size); + print_expression(type->size_expression); intern_print_type_post(type->base_type, false); } @@ -747,6 +747,8 @@ type_t *duplicate_type(const type_t *type) */ type_t *get_unqualified_type(type_t *type) { + assert(!is_typeref(type)); + if (type->base.qualifiers == TYPE_QUALIFIER_NONE) return type; @@ -776,12 +778,14 @@ type_t *get_qualified_type(type_t *orig_type, type_qualifiers_t const qual) copy = duplicate_type(type); copy->array.element_type = qual_element_type; - } else { + } else if (is_type_valid(type)) { if ((type->base.qualifiers & qual) == qual) return orig_type; copy = duplicate_type(type); copy->base.qualifiers |= qual; + } else { + return type; } type = typehash_insert(copy); @@ -929,9 +933,8 @@ bool is_type_arithmetic(const type_t *type) */ bool is_type_real(const type_t *type) { - /* 6.2.5.17 */ - return is_type_integer(type) - || (type->kind == TYPE_ATOMIC && is_type_float(type)); + /* 6.2.5 (17) */ + return is_type_integer(type) || is_type_float(type); } /** @@ -1022,6 +1025,9 @@ static bool function_types_compatible(const function_type_t *func1, if (!types_compatible(ret1, ret2)) return false; + if (func1->calling_convention != func2->calling_convention) + return false; + /* can parameters be compared? */ if (func1->unspecified_parameters || func2->unspecified_parameters) return true; @@ -1029,9 +1035,6 @@ static bool function_types_compatible(const function_type_t *func1, if (func1->variadic != func2->variadic) return false; - if (func1->calling_convention != func2->calling_convention) - return false; - /* TODO: handling of unspecified parameters not correct yet */ /* all argument types must be compatible */ @@ -1084,6 +1087,9 @@ bool types_compatible(const type_t *type1, const type_t *type2) if (type1 == type2) return true; + if (!is_type_valid(type1) || !is_type_valid(type2)) + return true; + if (type1->base.qualifiers != type2->base.qualifiers) return false; if (type1->kind != type2->kind)