mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Make alaising a def to a larger type an internal error.
It really doesn't seem wise to allow the compiler to do so as it would overwrite unrelated defs. The only time such a thing is valid is the return statement (silly vm design), and that's read-only.
This commit is contained in:
parent
9ca5a9e86c
commit
9d0332ae30
2 changed files with 3 additions and 4 deletions
|
@ -117,14 +117,12 @@ def_t *new_def (const char *name, struct type_s *type,
|
|||
/** Create a def that aliases another def.
|
||||
|
||||
Aliasing a def to the same type is useless, but not checked. Aliasing a
|
||||
def to a type larger than the def's type is a bad idea as another def may
|
||||
be overwritten via the alias, but is not checked.
|
||||
def to a type larger than the def's type will generate an internal error.
|
||||
|
||||
\param def The def to be aliased.
|
||||
\param type The type of the alias.
|
||||
\return The def aliasing \a def.
|
||||
|
||||
\todo Check for type size?
|
||||
\todo Make aliasing to the same type a no-op?
|
||||
*/
|
||||
def_t *alias_def (def_t *def, struct type_s *type);
|
||||
|
|
|
@ -149,13 +149,14 @@ alias_def (def_t *def, type_t *type)
|
|||
{
|
||||
def_t *alias;
|
||||
|
||||
|
||||
if (def->alias) {
|
||||
expr_t e;
|
||||
e.file = def->file;
|
||||
e.line = def->line;
|
||||
internal_error (&e, "aliasing an alias def");
|
||||
}
|
||||
if (type_size (type) > type_size (def->type))
|
||||
internal_error (0, "aliasing a def to a larger type");
|
||||
ALLOC (16384, def_t, defs, alias);
|
||||
alias->return_addr = __builtin_return_address (0);
|
||||
alias->offset = def->offset;
|
||||
|
|
Loading…
Reference in a new issue