From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, nathan@acm.org
Subject: Re: [PATCH] c++/modules: depending local enums [PR104919, PR106009]
Date: Fri, 1 Mar 2024 11:12:23 -0500 [thread overview]
Message-ID: <72695b26-0963-4530-9ee1-236b64829321@redhat.com> (raw)
In-Reply-To: <32846614-cd68-4912-8630-7b19098511d1@redhat.com>
On 3/1/24 10:32, Jason Merrill wrote:
> On 3/1/24 10:00, Patrick Palka wrote:
>> On Fri, 1 Mar 2024, Jason Merrill wrote:
>>
>>> On 2/29/24 15:56, Patrick Palka wrote:
>>>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look
>>>> OK for trunk?
>>>>
>>>> -- >8 --
>>>>
>>>> For local enums defined in a non-template function or a function
>>>> template
>>>> instantiation it seems we neglect to make the function depend on the
>>>> enum
>>>> definition, which ultimately causes streaming to fail due to the enum
>>>> definition not being streamed before uses of its enumerators are
>>>> streamed,
>>>> as far as I can tell.
>>>
>>> I would think that the function doesn't need to depend on the local
>>> enum in
>>> order for the local enum to be streamed before the use of the
>>> enumerator,
>>> which comes after the definition of the enum in the function body?
>>>
>>> Why isn't streaming the body of the function outputting the enum
>>> definition
>>> before the use of the enumerator?
>>
>> IIUC (based on observing the behavior for local classes) streaming the
>> definition of a local class/enum as part of the function definition is
>> what we want to avoid; we want to treat a local type definition as a
>> logically separate definition and stream it separately (similar
>> to class defns vs member defns I guess). And by not registering a
>> dependency
>> between the function and the local enum, we end up never streaming out
>> the local enum definition separately and instead stream it out as part
>> of the function definition (accidentally) which we then can't stream in
>> properly.
>>
>> Perhaps the motivation for treating local type definitions as logically
>> separate from the function definition is because they can leak out of a
>> function with a deduced return type:
>>
>> auto f() {
>> struct A { };
>> return A();
>> }
>>
>> using type = decltype(f()); // refers directly to f()::A
>
> Yes, I believe that's what modules.cc refers to as a "voldemort".
>
> But for non-voldemort local types, the declaration of the function
> doesn't depend on them, only the definition. Why doesn't streaming them
> in the definition work properly?
And does your 99426 patch address that problem?
Jason
next prev parent reply other threads:[~2024-03-01 16:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 20:56 Patrick Palka
2024-03-01 13:32 ` Jason Merrill
2024-03-01 15:00 ` Patrick Palka
2024-03-01 15:32 ` Jason Merrill
2024-03-01 16:12 ` Jason Merrill [this message]
2024-03-01 16:45 ` Patrick Palka
2024-03-01 17:52 ` Jason Merrill
2024-03-01 16:39 ` Patrick Palka
2024-03-01 17:08 ` Patrick Palka
2024-03-01 18:04 ` Jason Merrill
2024-03-01 18:28 ` Patrick Palka
2024-03-01 19:06 ` Jason Merrill
2024-03-01 19:34 ` Patrick Palka
2024-03-01 20:34 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=72695b26-0963-4530-9ee1-236b64829321@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nathan@acm.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).