From: Matthias Braun Date: Mon, 26 Nov 2007 20:00:50 +0000 (+0000) Subject: add some assert where typedef/typeof types should not be used, add missing skip_typer... X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=9c7de5fc04d3734014456b8d607ec64c4fcd19fa;p=cparser add some assert where typedef/typeof types should not be used, add missing skip_typeref in call semantic [r18543] --- diff --git a/parser.c b/parser.c index d35396f..b61c609 100644 --- a/parser.c +++ b/parser.c @@ -3188,6 +3188,7 @@ static expression_t *parse_call_expression(unsigned precedence, /* do default promotion */ for( ; argument != NULL; argument = argument->next) { type_t *type = argument->expression->datatype; + type = skip_typeref(type); if(type == NULL) continue; @@ -3197,6 +3198,7 @@ static expression_t *parse_call_expression(unsigned precedence, } else if(type == type_float) { type = type_double; } + argument->expression = create_implicit_cast(argument->expression, type); } diff --git a/type.c b/type.c index 92fcd15..446d035 100644 --- a/type.c +++ b/type.c @@ -349,6 +349,8 @@ bool type_valid(const type_t *type) bool is_type_integer(const type_t *type) { + assert(!is_typeref(type)); + if(type->type == TYPE_ENUM) return true; @@ -377,6 +379,8 @@ bool is_type_integer(const type_t *type) bool is_type_floating(const type_t *type) { + assert(!is_typeref(type)); + if(type->type != TYPE_ATOMIC) return false; @@ -401,6 +405,8 @@ bool is_type_floating(const type_t *type) bool is_type_signed(const type_t *type) { + assert(!is_typeref(type)); + /* enum types are int for now */ if(type->type == TYPE_ENUM) return true; @@ -448,6 +454,8 @@ bool is_type_signed(const type_t *type) bool is_type_arithmetic(const type_t *type) { + assert(!is_typeref(type)); + if(is_type_integer(type) || is_type_floating(type)) return 1; @@ -456,6 +464,8 @@ bool is_type_arithmetic(const type_t *type) bool is_type_scalar(const type_t *type) { + assert(!is_typeref(type)); + if(type->type == TYPE_POINTER) return 1; @@ -464,6 +474,8 @@ bool is_type_scalar(const type_t *type) bool is_type_incomplete(const type_t *type) { + assert(!is_typeref(type)); + switch(type->type) { case TYPE_COMPOUND_STRUCT: case TYPE_COMPOUND_UNION: { @@ -499,6 +511,9 @@ bool is_type_incomplete(const type_t *type) bool types_compatible(const type_t *type1, const type_t *type2) { + assert(!is_typeref(type1)); + assert(!is_typeref(type2)); + /* TODO: really incomplete */ if(type1 == type2) return true; @@ -515,6 +530,9 @@ bool types_compatible(const type_t *type1, const type_t *type2) bool pointers_compatible(const type_t *type1, const type_t *type2) { + assert(!is_typeref(type1)); + assert(!is_typeref(type2)); + assert(type1->type == TYPE_POINTER); assert(type2->type == TYPE_POINTER); #if 0 diff --git a/type_t.h b/type_t.h index 1df28af..209d778 100644 --- a/type_t.h +++ b/type_t.h @@ -161,4 +161,9 @@ static inline bool is_type_compound(const type_t *type) || type->type == TYPE_COMPOUND_UNION; } +static inline bool is_typeref(const type_t *type) +{ + return type->type == TYPE_TYPEDEF || type->type == TYPE_TYPEOF; +} + #endif