On 9/23/22 09:32, Patrick Palka wrote:
Judging by the two commits that introduced/modified this part of
maybe_register_incomplete_var, r196852 and r214333, ISTM the code
is really only concerned with constexpr static data members (whose
initializer may contain a pointer-to-member for a currently open class).
So maybe we ought to restrict the branch like so, which effectively
disables this part of maybe_register_incomplete_var during stream-in, and
guarantees that outermost_open_class doesn't return NULL if the branch is
taken?
I think the problem is that we're streaming these VAR_DECLs as regular
VAR_DECLS, when we should be handling them as a new kind of object
fished out from the template they're instantiating. (I'm guessing
that'll just be a new tag, a type and an initializer?)
Then on stream-in we can handle them in the same way as a non-modules
compilation handles such redeclarations. I.e. how does:
template<auto> struct C { };
struct A { };
C<A{}> c1; // #1
C<A{}> c2; // #2
work. Presumably at some point #2's A{} gets unified such that we find
the instantation that occurred at #1?
I notice the template arg for C<A{}> is a var decl mangled as
_ZTAXtl1AEE, which is a 'template paramete object for A{}'. I see
that's a special mangler 'mangle_template_parm_object', called from
get_template_parm_object. Perhaps these VAR_DECLs need an additional
in-tree flag that the streamer can check for?
nathan
--
Nathan Sidwell