mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[qfcc] Allow redefined typedefs if the same type
This fixes typeredef1, and will allow typeredef2 to pass once the grammar is sorted out.
This commit is contained in:
parent
e974e9d758
commit
5f22a322df
1 changed files with 10 additions and 2 deletions
|
@ -399,7 +399,14 @@ use_type_name (specifier_t spec)
|
||||||
spec.sym = new_symbol (spec.sym->name);
|
spec.sym = new_symbol (spec.sym->name);
|
||||||
spec.sym->type = spec.type;
|
spec.sym->type = spec.type;
|
||||||
spec.sym->sy_type = sy_var;
|
spec.sym->sy_type = sy_var;
|
||||||
symtab_addsymbol (current_symtab, spec.sym);
|
symbol_t *s = symtab_addsymbol (current_symtab, spec.sym);
|
||||||
|
// a different symbol being returned means that this is a redefinition
|
||||||
|
// of that symbol in the same scope. However, typedefs to the same type
|
||||||
|
// are allowed.
|
||||||
|
if (s != spec.sym && spec.is_typedef && s->sy_type == sy_type
|
||||||
|
&& type_same (s->type, spec.type)) {
|
||||||
|
spec.sym = s;
|
||||||
|
}
|
||||||
return !!spec.sym->table;
|
return !!spec.sym->table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +427,8 @@ check_specifiers (specifier_t spec)
|
||||||
bug (0, "wha? %p %p", spec.type, spec.sym);
|
bug (0, "wha? %p %p", spec.type, spec.sym);
|
||||||
} else {
|
} else {
|
||||||
// a type name (id, typedef, etc) was used as a variable name.
|
// a type name (id, typedef, etc) was used as a variable name.
|
||||||
// this is allowed in C, so long as it's in a different scope
|
// this is allowed in C, so long as it's in a different scope,
|
||||||
|
// or the types are the same
|
||||||
if (!use_type_name (spec)) {
|
if (!use_type_name (spec)) {
|
||||||
error (0, "%s redeclared as different kind of symbol",
|
error (0, "%s redeclared as different kind of symbol",
|
||||||
spec.sym->name);
|
spec.sym->name);
|
||||||
|
|
Loading…
Reference in a new issue