Fix sym_scope of typedefs
commit605538f46d277fe0931f72f032a24a675417ee2a
authorMichael Matz <matz@suse.de>
Wed, 22 Feb 2023 16:59:31 +0000 (22 17:59 +0100)
committerMichael Matz <matz@suse.de>
Wed, 22 Feb 2023 16:59:31 +0000 (22 17:59 +0100)
treeb59e4a166737484a8d4ca0243cea9b08d661240c
parentbdec3c534583066cf097543f265ad620a8baa30d
Fix sym_scope of typedefs

Sym.sym_scope and Sym.f (FuncAttr) share space, so blindly setting
one clobbers the other.  Right now this only leads to missing errors
on incompatible typedefs (see testcase), which this commit fixes.

But it points to a larger problem:
Generally we can only manipulate Sym.f for anonymous and field symbols,
not for anything that has a top-level name (basically any proper decl),
because the latter use sym_scope.  Luckily the functions type always
contains an anonymous symbol (in sym->type.ref), so we can use that.
But some of the functions attributes actually _do_ apply to the decl,
not the type (e.g. always_inline), so we still have a problem possibly,
when we update an pre-existing type that may already be shared with
another decl.

Would need untangling and perhaps using accessor functions that check
that Sym.f and Sym.sym_scope aren't used for the same symbol.
tccgen.c
tests/tests2/60_errors_and_warnings.c
tests/tests2/60_errors_and_warnings.expect