On Mon, Oct 25, 2021 at 12:46:30PM +0200, Richard Biener wrote: > On Thu, Oct 21, 2021 at 5:42 PM Segher Boessenkool > <seg...@kernel.crashing.org> wrote: > > It's disgusting, and fragile. The define is slightly better than having > > to write it out every time. But can this not be done properly? > > > > If you use object-oriented stuff and need casts for that, you are doing > > something wrong. > > I think the "proper" fix would be to make 'casm' have the correct type > in the first place
+1 > - of course that would either mean that the target > needs to provide the (possibly derived) type, for example via a typedef > in the target structure or a classical target macro. If gengtype would > know about inheritance that would also fix the GC marking issue. Do we want gengtype to do inheritance, will it solve more future problems, or will it *cause* more problems later? > Of course encoding a static type in the target structure is the > wrong direction from making targets "switchable". Yes. > Other than that my C++ fu is too weak to suggest the correct "pattern" > here. Virtual functions something something? Segher