From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id 2C7713858412 for ; Mon, 24 Oct 2022 12:39:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2C7713858412 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-x731.google.com with SMTP id m6so5945819qkm.4 for ; Mon, 24 Oct 2022 05:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=dLaS6+gO+dAJPgP2W9B1JoBTjCYWanA804UMZ00VdpY=; b=GGK0/rajPxEDaYQa/IeqWAw2GMY/o/uPaygrxVMUPJESbXV4sbD7dC8qTTuBSNvt2O HdqgyKJ58Exd7lzESBzuGT6JNQm9OiHUT4EPGkJJCLi0ul6Bp5js911em4pAwfP4RbLw tHvLdO7TUDV4x7lwDZ5RkLlnSumkKALnW05GLxmtBkxdnDWQa6+GHkyPDOLrcWc9dS5a 4AP7p4WlNmga9Csm/uEjfr4hZFZ8UWbtXtbfTfGg9H34cBhaPsTJ/kO6RGDnynxgqN3o Mzz2s2sdePebl4Ipy/I1GGz4LtJ0bvusnw5dBMGivKi6KB2pB1TxWGzRCJnTxcxnNT2J iRqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dLaS6+gO+dAJPgP2W9B1JoBTjCYWanA804UMZ00VdpY=; b=HsqKKfCIobD5AZSNrr93/CcjgH7mgtEcUUd9o9rPVjgyYUzdzr7YBVjG348e0uTNfK tpqLeTtNZ4VqKarTjEahXrXsMqAkiqEjscX9jcqQ0t3e/5ty0B9AyjsBaj7/4QMrspzk sd9Nf/7aULFX17xufBiUq6HVNPgw4fZS8vXOblM115ZXCn1zK7SWp4qUOxut1k+0c16R 3aaeBgskVLCwIXytqhHoInxJoDEJM7gJSgSZyUHzREuzMIyL9OpchHUSVm4aZVe6KEQ+ /dFg8sRUUNSZ65Tkuh2c+fSUiLoc3gvDNJ59Zo+VFHwuL+p6LYo29BGPHFHS2sIPCWwo Ml/w== X-Gm-Message-State: ACrzQf1DU7q89iQkhaq++wdQz2V0ZkpvWElr1krCQAut4LFndc80NtEV IC3qj6e3QHuct5SvG0YJwao= X-Google-Smtp-Source: AMsMyM63qfzDYgip+QIEfvUkusBmh1eU95hjoVa/LkxawkgpkXt33Vb3a31e2JdhRzfYW6jVf/DZ6w== X-Received: by 2002:a05:620a:b10:b0:6ec:1601:bc75 with SMTP id t16-20020a05620a0b1000b006ec1601bc75mr23729740qkg.730.1666615154193; Mon, 24 Oct 2022 05:39:14 -0700 (PDT) Received: from ?IPV6:2601:19c:527f:bfd0::5? ([2601:19c:527f:bfd0::5]) by smtp.googlemail.com with ESMTPSA id w27-20020a05620a0e9b00b006cdd0939ffbsm14631015qkm.86.2022.10.24.05.39.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 05:39:13 -0700 (PDT) Sender: Nathan Sidwell Message-ID: Date: Mon, 24 Oct 2022 08:39:13 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH] c++ modules: verify_type failure with typedef enum [PR106848] Content-Language: en-US To: Patrick Palka Cc: Richard Biener , gcc-patches@gcc.gnu.org References: <20221013153921.3795800-1-ppalka@redhat.com> <5cf07598-68ce-efda-05c3-625a1466195f@idea> <5601279b-939f-4492-c14b-c495d7a2a3b2@idea> <2072c1af-9f73-3c9d-8c52-f0edf82e289f@acm.org> <617594a2-c890-948f-9215-8d58c6c8f473@idea> From: Nathan Sidwell In-Reply-To: <617594a2-c890-948f-9215-8d58c6c8f473@idea> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3039.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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