diff options
author | Michael Forney <mforney@mforney.org> | 2019-04-06 12:50:23 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-04-06 12:50:23 -0700 |
commit | 685ad141faaf6ee033accac8b15947f53862bcd0 (patch) | |
tree | cac77d833ba879f8420363c65bbd1442f4d4d4bb | |
parent | 6f65c9e5564d89e0512a80ae0301330c31dbc6e5 (diff) |
Use common code for checking for compatibility of base type for derived types
-rw-r--r-- | type.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -162,14 +162,12 @@ typecompatible(struct type *t1, struct type *t2) case TYPEVOID: return true; case TYPEPOINTER: - return t1->qual == t2->qual && typecompatible(t1->base, t2->base); + goto derived; case TYPEARRAY: if (t1->array.length && t2->array.length && t1->array.length != t2->array.length) return false; - return t1->qual == t2->qual && typecompatible(t1->base, t2->base); + goto derived; case TYPEFUNC: - if (t1->qual != t2->qual || !typecompatible(t1->base, t2->base)) - return false; if (!t1->func.isprototype) { if (!t2->func.isprototype) return true; @@ -191,7 +189,11 @@ typecompatible(struct type *t1, struct type *t2) if (!typecompatible(p1->type, tmp)) return false; } - return !p1 && !p2; + if (p1 || p2) + return false; + goto derived; + derived: + return t1->qual == t2->qual && typecompatible(t1->base, t2->base); } return false; } |