On Tue, Dec 17, 2024 at 05:34:38PM -0500, Jason Merrill wrote: > On 9/11/24 8:26 AM, Jakub Jelinek wrote: > > On Wed, Sep 11, 2024 at 10:16:18PM +1000, Nathaniel Shead wrote: > > > In the header_module_p case, it is valid to have internal linkage > > > definitions (e.g. in an anonymous namespace), but in that case the > > > {static,tls}_aggregates lists should still be in place to be streamed > > > and everything should work as "normal". > > > > As the patch doesn't touch the streaming of {static,tls}_aggregates > > in that case, I guess that means CWG 2867 will not be fixed for those > > cases (i.e. temporaries from the structured binding base initialization > > will be destructed at the end of that initialization, rather than at the > > end of subsequent get initializers); perhaps we should stream the > > STATIC_INIT_DECOMP_*BASE_P flags say by streaming there integer_zero_node > > or integer_one_node right before the decls and on streaming it back set > > the flags again. > > We don't stream *_aggregates at all; rather, read_var_def builds them up as > we read in the variables. Can we set the appropriate flags at that time?
I know we don't stream *_aggregates, that makes it even harder. We'd need to ensure that we stream either all the decls coming from a namespace scope structured binding, or none of them, in the right order (no idea if that is already guaranteed somehow or would need to be extra ensured and where). Then probably write_var_def would need to stream the STATIC_INIT_DECOMP_NONBASE_P/STATIC_INIT_DECOMP_BASE_P flags (or arrange for them to be streamed out later) and then in read_var_def stream that in (or again arrange for it to be streamed in later). In order to implement that, guess I'd first need to have a testcase I can look at it. I don't see a single dg-do run testcase in g++.dg/modules/ though. Would that be something like add *.H file with // { dg-additional-options "-fmodule-header" } // { dg-module-cmi {} } and content like in one of the testcases in the patch with non-std stuff moded all into anonymous namespace, then // { dg-do run } // { dg-additional-options "-fmodules-ts" } import "name.H"; int main () { // use the sb vars and perhaps assert counters have the expected state } ? > > For the !header_module_p case, we'll need a testcase too > > to make sure it works properly. > > For the !header_module_p case, the structured binding initialization would > be handled by the module .o, so importers wouldn't need to worry about it. Ok. Jakub