cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 685ad141faaf6ee033accac8b15947f53862bcd0
parent 6f65c9e5564d89e0512a80ae0301330c31dbc6e5
Author: Michael Forney <mforney@mforney.org>
Date:   Sat,  6 Apr 2019 12:50:23 -0700

Use common code for checking for compatibility of base type for derived types

Diffstat:
Mtype.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/type.c b/type.c @@ -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; }