public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: Patrick Palka <ppalka@redhat.com>
Cc: Richard Biener <richard.guenther@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++ modules: verify_type failure with typedef enum [PR106848]
Date: Mon, 24 Oct 2022 08:39:13 -0400	[thread overview]
Message-ID: <f21c412f-e25d-90a6-d740-05d2c2985e4e@acm.org> (raw)
In-Reply-To: <617594a2-c890-948f-9215-8d58c6c8f473@idea>

On 10/21/22 09:11, Patrick Palka wrote:
> On Fri, 21 Oct 2022, Nathan Sidwell wrote:

>>
>> Thanks for the explanation, it's a situation I didn;t anticipate and your fix
>> is good.  Could you add a comment about why you need to propagate the values
>> though?
> 
> Thanks a lot, will do.  Just to make sure since there are multiple
> solutions proposed, do you prefer to go with
> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603487.html
> or
> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603831.html ?
> 
> Both solutions fix the PR106848 issue (empty TYPE_MIN/MAX_VALUE on an
> enum type variant), but the latter also fixes the related PR102600
> (empty TYPE_MIN/MAX_VALUE on the main variant of an enum with no
> enumerators).  (We could maybe even combine the two solutions: stream
> TYPE_MIN/MAX_VALUE as part of ENUMERAL_TYPE, and also update TYPE_VALUES
> of each variant during trees_in::read_enum_def)


Oh, let's go with the latter:

	* module.cc (trees_out::core_vals): Stream TYPE_MAX_VALUE and
	TYPE_MIN_VALUE of ENUMERAL_TYPE.
	(trees_in::core_vals): Likewise.
	(trees_out::write_enum_def): Don't stream them here.
	(trees_in::read_enum_def): Likewise.

but, again, some comments -- at the new streaming point, and in the defn 
streamer were we no longer stream them.

thanks.

> 
>>
>> nathan
>>
>>>
>>>>
>>>>> A somewhat orthogonal issue (that incidentally fixes this testcase) is
>>>>> that we stream TYPE_MIN/MAX_VALUE only for enums with a definition, but
>>>>> the frontend sets these fields even for opaque enums.  If we make sure
>>>>> to stream these fields for all ENUMERAL_TYPEs, then we won't have to
>>>>> worry about these fields being stale for variants that may have been
>>>>> created before reading in the enum definition (their TYPE_VALUES field
>>>>> will still be stale I guess, but verify_type doesn't worry about that
>>>>> it seems, so we avoid the ICE).
>>>>>
>>>>> patch to that effect is at
>>>>> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603831.html
>>>>>
>>>>>>
>>>>>> Richard.
>>>>>>
>>>>>>>
>>>>>>>          rest_of_type_compilation (type, DECL_NAMESPACE_SCOPE_P
>>>>>>> (defn));
>>>>>>>        }
>>>>>>> diff --git a/gcc/testsuite/g++.dg/modules/enum-9_a.H
>>>>>>> b/gcc/testsuite/g++.dg/modules/enum-9_a.H
>>>>>>> new file mode 100644
>>>>>>> index 00000000000..fb7d10ad3b6
>>>>>>> --- /dev/null
>>>>>>> +++ b/gcc/testsuite/g++.dg/modules/enum-9_a.H
>>>>>>> @@ -0,0 +1,5 @@
>>>>>>> +// PR c++/106848
>>>>>>> +// { dg-additional-options -fmodule-header }
>>>>>>> +// { dg-module-cmi {} }
>>>>>>> +
>>>>>>> +typedef enum memory_order { memory_order_seq_cst } memory_order;
>>>>>>> diff --git a/gcc/testsuite/g++.dg/modules/enum-9_b.C
>>>>>>> b/gcc/testsuite/g++.dg/modules/enum-9_b.C
>>>>>>> new file mode 100644
>>>>>>> index 00000000000..63e81675d0a
>>>>>>> --- /dev/null
>>>>>>> +++ b/gcc/testsuite/g++.dg/modules/enum-9_b.C
>>>>>>> @@ -0,0 +1,6 @@
>>>>>>> +// PR c++/106848
>>>>>>> +// { dg-additional-options "-fmodules-ts -g" }
>>>>>>> +
>>>>>>> +import "enum-9_a.H";
>>>>>>> +
>>>>>>> +memory_order x = memory_order_seq_cst;
>>>>>>> --
>>>>>>> 2.38.0.68.ge85701b4af
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>> -- 
>> Nathan Sidwell
>>
>>
> 

-- 
Nathan Sidwell


  reply	other threads:[~2022-10-24 12:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 15:39 Patrick Palka
2022-10-14  6:04 ` Richard Biener
2022-10-18 18:26   ` Patrick Palka
2022-10-19  7:33     ` Richard Biener
2022-10-19 13:55       ` Patrick Palka
2022-10-21 12:36         ` Nathan Sidwell
2022-10-21 13:11           ` Patrick Palka
2022-10-24 12:39             ` Nathan Sidwell [this message]
2022-10-25 17:46               ` Patrick Palka

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=f21c412f-e25d-90a6-d740-05d2c2985e4e@acm.org \
    --to=nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    --cc=richard.guenther@gmail.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).