diff --git a/tccgen.c b/tccgen.c index 8f4cd13a..fa190597 100644 --- a/tccgen.c +++ b/tccgen.c @@ -2893,6 +2893,8 @@ static int compare_types(CType *type1, CType *type2, int unqualified) if (bt1 == VT_PTR) { type1 = pointed_type(type1); type2 = pointed_type(type2); + if (unqualified && (t1 & VT_ARRAY)) + return compare_types(type1, type2, 1); return is_compatible_types(type1, type2); } else if (bt1 == VT_STRUCT) { return (type1->ref == type2->ref); @@ -5815,9 +5817,7 @@ ST_FUNC void unary(void) break; case TOK_builtin_types_compatible_p: parse_builtin_params(0, "tt"); - vtop[-1].type.t &= ~(VT_CONSTANT | VT_VOLATILE); - vtop[0].type.t &= ~(VT_CONSTANT | VT_VOLATILE); - n = is_compatible_types(&vtop[-1].type, &vtop[0].type); + n = compare_types(&vtop[-1].type, &vtop[0].type, 1); vtop -= 2; vpushi(n); break; diff --git a/tests/tcctest.c b/tests/tcctest.c index 38d27fcf..e275bf6c 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -3953,6 +3953,9 @@ void builtin_test(void) COMPAT_TYPE(int, char); COMPAT_TYPE(int, const int); COMPAT_TYPE(int, volatile int); + COMPAT_TYPE(int[2], const int[2]); + COMPAT_TYPE(int[2][3], volatile int[][3]); + COMPAT_TYPE(int (*)[], const int (*)[]); COMPAT_TYPE(int *, int *); COMPAT_TYPE(int *, void *); COMPAT_TYPE(int *, const int *);