aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorbellard <bellard>2006-10-28 14:13:28 +0000
committerbellard <bellard>2006-10-28 14:13:28 +0000
commit24a19cc37e7884e9994a0fd63a96ba1ee31e207f (patch)
tree806f6f96fe1d152267d7c52f5d233db4e4ec9354 /tcc.c
parent38d2e8b9d8dae9680603d66fe51c1b287141bd7e (diff)
downloadtinycc-24a19cc37e7884e9994a0fd63a96ba1ee31e207f.tar.gz
tinycc-24a19cc37e7884e9994a0fd63a96ba1ee31e207f.tar.bz2
discard type qualifiers when comparing function parameters (Dave Dodge)
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/tcc.c b/tcc.c
index ac22162..512c9e5 100644
--- a/tcc.c
+++ b/tcc.c
@@ -801,7 +801,9 @@ static int pointed_size(CType *type);
static int lvalue_type(int t);
static int parse_btype(CType *type, AttributeDef *ad);
static void type_decl(CType *type, AttributeDef *ad, int *v, int td);
+static int compare_types(CType *type1, CType *type2, int unqualified);
static int is_compatible_types(CType *type1, CType *type2);
+static int is_compatible_parameter_types(CType *type1, CType *type2);
int ieee_finite(double d);
void error(const char *fmt, ...);
@@ -6007,7 +6009,7 @@ static int is_compatible_func(CType *type1, CType *type2)
while (s1 != NULL) {
if (s2 == NULL)
return 0;
- if (!is_compatible_types(&s1->type, &s2->type))
+ if (!is_compatible_parameter_types(&s1->type, &s2->type))
return 0;
s1 = s1->next;
s2 = s2->next;
@@ -6017,17 +6019,22 @@ static int is_compatible_func(CType *type1, CType *type2)
return 1;
}
-/* return true if type1 and type2 are exactly the same (including
- qualifiers).
+/* return true if type1 and type2 are the same. If unqualified is
+ true, qualifiers on the types are ignored.
- enums are not checked as gcc __builtin_types_compatible_p ()
*/
-static int is_compatible_types(CType *type1, CType *type2)
+static int compare_types(CType *type1, CType *type2, int unqualified)
{
int bt1, t1, t2;
t1 = type1->t & VT_TYPE;
t2 = type2->t & VT_TYPE;
+ if (unqualified) {
+ /* strip qualifiers before comparing */
+ t1 &= ~(VT_CONSTANT | VT_VOLATILE);
+ t2 &= ~(VT_CONSTANT | VT_VOLATILE);
+ }
/* XXX: bitfields ? */
if (t1 != t2)
return 0;
@@ -6046,6 +6053,21 @@ static int is_compatible_types(CType *type1, CType *type2)
}
}
+/* return true if type1 and type2 are exactly the same (including
+ qualifiers).
+*/
+static int is_compatible_types(CType *type1, CType *type2)
+{
+ return compare_types(type1,type2,0);
+}
+
+/* return true if type1 and type2 are the same (ignoring qualifiers).
+*/
+static int is_compatible_parameter_types(CType *type1, CType *type2)
+{
+ return compare_types(type1,type2,1);
+}
+
/* print a type. If 'varstr' is not NULL, then the variable is also
printed in the type */
/* XXX: union */