diff --git a/tools/qfcc/include/type.h b/tools/qfcc/include/type.h index 12fe4e94c..45950fdc9 100644 --- a/tools/qfcc/include/type.h +++ b/tools/qfcc/include/type.h @@ -149,6 +149,7 @@ void print_type (const type_t *type); const char *encode_params (const type_t *type); void encode_type (struct dstring_s *encoding, const type_t *type); const char *type_get_encoding (const type_t *type); +int is_void (const type_t *type); int is_enum (const type_t *type); int is_integral (const type_t *type); int is_float (const type_t *type); diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index c68935a40..262f26964 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -649,6 +649,12 @@ encode_type (dstring_t *encoding, const type_t *type) } } +int +is_void (const type_t *type) +{ + return type->type == ev_void; +} + int is_enum (const type_t *type) { @@ -724,13 +730,12 @@ type_assignable (const type_t *dst, const type_t *src) if (dst->type == ev_field && src->type == ev_field) return 1; // pointer = array - if (dst->type == ev_pointer - && src->type == ev_invalid && src->meta == ty_array) { + if (is_pointer (dst) && is_array (src)) { if (dst->t.fldptr.type == src->t.array.type) return 1; return 0; } - if (dst->type != ev_pointer || src->type != ev_pointer) + if (!is_pointer (dst) || !is_pointer (src)) return is_scalar (dst) && is_scalar (src); // pointer = pointer @@ -743,9 +748,9 @@ type_assignable (const type_t *dst, const type_t *src) dst = dst->t.fldptr.type; src = src->t.fldptr.type; - if (dst->type == ev_void) + if (is_void (dst)) return 1; - if (src->type == ev_void) + if (is_void (src)) return 1; return 0; }