simplify testcase
[cparser] / type.c
diff --git a/type.c b/type.c
index d7aaab5..59d7722 100644 (file)
--- a/type.c
+++ b/type.c
@@ -1023,22 +1023,6 @@ bool types_compatible(const type_t *type1, const type_t *type2)
        return false;
 }
 
-/**
- * Check if two pointer types are compatible.
- */
-bool pointers_compatible(const type_t *type1, const type_t *type2)
-{
-       assert(!is_typeref(type1));
-       assert(!is_typeref(type2));
-
-       assert(type1->kind == TYPE_POINTER);
-       assert(type2->kind == TYPE_POINTER);
-       (void) type1;
-       (void) type2;
-       /* TODO */
-       return true;
-}
-
 /**
  * Skip all typerefs and return the underlying type.
  */
@@ -1076,8 +1060,18 @@ type_t *skip_typeref(type_t *type)
        }
 
        if (qualifiers != TYPE_QUALIFIER_NONE) {
-               type_t *const copy     = duplicate_type(type);
-               copy->base.qualifiers |= qualifiers;
+               type_t *const copy = duplicate_type(type);
+
+               /* for const with typedefed array type the element type has to be
+                * adjusted */
+               if (is_type_array(copy)) {
+                       type_t *element_type           = copy->array.element_type;
+                       element_type                   = duplicate_type(element_type);
+                       element_type->base.qualifiers |= qualifiers;
+                       copy->array.element_type       = element_type;
+               } else {
+                       copy->base.qualifiers |= qualifiers;
+               }
 
                type = typehash_insert(copy);
                if (type != copy) {