Propagate type qualifiers in skip_typeref().
authorChristoph Mallon <christoph.mallon@gmx.de>
Tue, 11 Dec 2007 08:45:59 +0000 (08:45 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 11 Dec 2007 08:45:59 +0000 (08:45 +0000)
[r18668]

type.c

diff --git a/type.c b/type.c
index 8568ed6..ddfb8d0 100644 (file)
--- a/type.c
+++ b/type.c
@@ -689,7 +689,7 @@ bool pointers_compatible(const type_t *type1, const type_t *type2)
 
 type_t *skip_typeref(type_t *type)
 {
-       unsigned qualifiers = type->base.qualifiers;
+       unsigned qualifiers = TYPE_QUALIFIER_NONE;
 
        while(true) {
                switch(type->kind) {
@@ -718,6 +718,16 @@ type_t *skip_typeref(type_t *type)
                break;
        }
 
+       if (qualifiers != TYPE_QUALIFIER_NONE) {
+               type_t *const copy     = duplicate_type(type);
+               copy->base.qualifiers |= qualifiers;
+
+               type = typehash_insert(copy);
+               if (type != copy) {
+                       obstack_free(type_obst, copy);
+               }
+       }
+
        return type;
 }