mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
Allow casting between string and pointer types
This commit is contained in:
parent
a6f3e1753a
commit
b00c866c4e
3 changed files with 14 additions and 0 deletions
|
@ -166,6 +166,7 @@ int is_field (const type_t *type) __attribute__((pure));
|
|||
int is_struct (const type_t *type) __attribute__((pure));
|
||||
int is_array (const type_t *type) __attribute__((pure));
|
||||
int is_func (const type_t *type) __attribute__((pure));
|
||||
int is_string (const type_t *type) __attribute__((pure));
|
||||
int type_compatible (const type_t *dst, const type_t *src) __attribute__((pure));
|
||||
int type_assignable (const type_t *dst, const type_t *src);
|
||||
int type_size (const type_t *type) __attribute__((pure));
|
||||
|
|
|
@ -2595,6 +2595,11 @@ cast_expr (type_t *type, expr_t *e)
|
|||
if ((type == type_default && is_enum (e_type))
|
||||
|| (is_enum (type) && e_type == type_default))
|
||||
return e;
|
||||
if ((is_pointer (type) && is_string (e_type))
|
||||
|| (is_string (type) && is_pointer (e_type))) {
|
||||
c = new_alias_expr (type, e);
|
||||
return c;
|
||||
}
|
||||
if (!(type->type == ev_pointer
|
||||
&& (e_type->type == ev_pointer || is_integral (e_type)
|
||||
|| is_array (e_type)))
|
||||
|
|
|
@ -785,6 +785,14 @@ is_func (const type_t *type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
is_string (const type_t *type)
|
||||
{
|
||||
if (type->type == ev_string)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
type_compatible (const type_t *dst, const type_t *src)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue