mirror of
git://repo.or.cz/tinycc.git
synced 2026-11-04 21:26:36 +08:00
tccgen: match GCC for qualified array types
__builtin_types_compatible_p ignores qualifiers exposed through array type derivations in GCC and Clang, whereas it does not in TCC. This fix uses the existing unqualified comparison recursively for array types, while continuing to preserve qualifiers on referenced types.
This commit is contained in:
parent
0fb54300b5
commit
4666db3288
6
tccgen.c
6
tccgen.c
@ -2893,6 +2893,8 @@ static int compare_types(CType *type1, CType *type2, int unqualified)
|
|||||||
if (bt1 == VT_PTR) {
|
if (bt1 == VT_PTR) {
|
||||||
type1 = pointed_type(type1);
|
type1 = pointed_type(type1);
|
||||||
type2 = pointed_type(type2);
|
type2 = pointed_type(type2);
|
||||||
|
if (unqualified && (t1 & VT_ARRAY))
|
||||||
|
return compare_types(type1, type2, 1);
|
||||||
return is_compatible_types(type1, type2);
|
return is_compatible_types(type1, type2);
|
||||||
} else if (bt1 == VT_STRUCT) {
|
} else if (bt1 == VT_STRUCT) {
|
||||||
return (type1->ref == type2->ref);
|
return (type1->ref == type2->ref);
|
||||||
@ -5815,9 +5817,7 @@ ST_FUNC void unary(void)
|
|||||||
break;
|
break;
|
||||||
case TOK_builtin_types_compatible_p:
|
case TOK_builtin_types_compatible_p:
|
||||||
parse_builtin_params(0, "tt");
|
parse_builtin_params(0, "tt");
|
||||||
vtop[-1].type.t &= ~(VT_CONSTANT | VT_VOLATILE);
|
n = compare_types(&vtop[-1].type, &vtop[0].type, 1);
|
||||||
vtop[0].type.t &= ~(VT_CONSTANT | VT_VOLATILE);
|
|
||||||
n = is_compatible_types(&vtop[-1].type, &vtop[0].type);
|
|
||||||
vtop -= 2;
|
vtop -= 2;
|
||||||
vpushi(n);
|
vpushi(n);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -3953,6 +3953,9 @@ void builtin_test(void)
|
|||||||
COMPAT_TYPE(int, char);
|
COMPAT_TYPE(int, char);
|
||||||
COMPAT_TYPE(int, const int);
|
COMPAT_TYPE(int, const int);
|
||||||
COMPAT_TYPE(int, volatile 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 *, int *);
|
||||||
COMPAT_TYPE(int *, void *);
|
COMPAT_TYPE(int *, void *);
|
||||||
COMPAT_TYPE(int *, const int *);
|
COMPAT_TYPE(int *, const int *);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user