[{"id":3675970,"web_url":"http://patchwork.ozlabs.org/comment/3675970/","msgid":"<44f07990-49b4-4836-803d-818700c49ee2@redhat.com>","list_archive_url":null,"date":"2026-04-10T16:20:03","subject":"Re: [PATCH] c++: Include anon enum types in namespace members_of\n [PR124831]","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On 4/10/26 3:45 AM, Jakub Jelinek wrote:\n> Hi!\n> \n> As the testcase shows, we have similar problem with namespace scope\n> anonymous enums like we have with namespace scope anonymous unions.\n> Because they are anonymous, in neither case we emit anything into the\n> namespace bindings but we should still list those.\n> Now, for anonymous union this is done by adding it (once only) when\n> seeing corresponding DECL_ANON_UNION_VAR_P (and it doesn't work when there\n> is anon union without any members but that is a pedwarn anyway).\n> \n> The following patch handles it similarly for anon enums, namespace scope\n> enum {}; is still ignored (but that is a pedwarn as well, so not a big deal)\n> and when there is at least one enumerator in it, we add it when seeing\n> the CONST_DECL (but again, just once for the whole members_of call).\n> \n> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?\n> \n> 2026-04-10  Jakub Jelinek  <jakub@redhat.com>\n> \n> \tPR c++/124831\n> \t* reflect.cc (namespace_members_of): Append reflection of anon unions\n> \twhen we see it first time as CP_DECL_CONTEXT of some CONST_DECL in\n> \tthe namespace.\n> \n> \t* g++.dg/reflect/members_of13.C: New test.\n> \n> --- gcc/cp/reflect.cc.jj\t2026-04-08 15:40:47.318192269 +0200\n> +++ gcc/cp/reflect.cc\t2026-04-09 16:02:19.379053882 +0200\n> @@ -6760,6 +6760,24 @@ namespace_members_of (location_t loc, tr\n>   \t  return;\n>   \t}\n>   \n> +      if (TREE_CODE (b) == CONST_DECL\n> +\t  && enum_with_enumerator_for_linkage_p (CP_DECL_CONTEXT (b))\n> +\t  && members_of_representable_p (data->ns, CP_DECL_CONTEXT (b)))\n> +\t{\n> +\t  /* TODO: This doesn't handle namespace N { enum {}; }\n> +\t     but we pedwarn on that, so perhaps it doesn't need to be\n> +\t     handled.  */\n\nYes, this violates https://eel.is/c++draft/dcl#pre-6 so does not need to \nbe handled.  OK with that clarification.\n\nJason","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=AD3QO4EX;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=AD3QO4EX","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.129.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fshqX00Y7z1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 11 Apr 2026 02:20:39 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 1CB1F4BA2E1E\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 16:20:38 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id E55FD4BA2E0F\n for <gcc-patches@gcc.gnu.org>; Fri, 10 Apr 2026 16:20:08 +0000 (GMT)","from mail-qv1-f70.google.com (mail-qv1-f70.google.com\n [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-453-FVa70Fl-MYGSDhRqB053Iw-1; Fri, 10 Apr 2026 12:20:07 -0400","by mail-qv1-f70.google.com with SMTP id\n 6a1803df08f44-89ce2a7fef6so59998686d6.1\n for <gcc-patches@gcc.gnu.org>; Fri, 10 Apr 2026 09:20:07 -0700 (PDT)","from [192.168.50.130]\n (130-44-146-247.s12789.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com.\n [130.44.146.247]) by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8ac902cb140sm5747086d6.12.2026.04.10.09.20.03\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Fri, 10 Apr 2026 09:20:04 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 1CB1F4BA2E1E","OpenDKIM Filter v2.11.0 sourceware.org E55FD4BA2E0F"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org E55FD4BA2E0F","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org E55FD4BA2E0F","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775838009; cv=none;\n b=XosKrFA2M4oB/v6CT2NmJUzrRxWiFF9w3RjnSziwzxict25RyNZnPAUJBlEpW9zHdkIDgPtkyGxNQYtRLv7vMOSsI2RQ5kZTBagm87eO9etxsdw/jiLquykzgtvR1XdW5pP9XYxOgsyixy+eNKyOlTrTcF2mab2RP7lLNP/IG7E=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775838009; c=relaxed/simple;\n bh=4ivrXbk2AFvTKSzlgTDCDc9mhxjh88qSKu1afDRoTKQ=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=OHozfV5rLXgvjhReft+u8JdmRsmfaZSISgxqAAEr4qbCjQcrVZwB4ryU0OtQsIQMWHF7a7d9lOxcjDFU6YcSttZ9EFTd0hLdhZ8393dnayJ9xt1zh97QRVYDvdlPSFUrbnEO5H/wGwr+orq6r/1kl+xN8TTcQmAdFjSDJ/qTDto=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775838008;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=17KGi7Zl8vKY2folMPByBKuwGvjFHMjz2nXSyocVZAk=;\n b=AD3QO4EX5dSODeMJ2OwVpc4MVHljQ4ZeOcDQ5K5MFkWIMxVqqfAxiXWrhtoQB+3Ugj1lNW\n c0cnfd1HiuPQAk4oouhIGWINeNDwOlBXL4yXruGps9o5H9qZTUxl6Vi91aQ7KC2mVL2XGC\n MQ1wkI6AZ1NXu+2bgCPFwH59+TranB4=","X-MC-Unique":"FVa70Fl-MYGSDhRqB053Iw-1","X-Mimecast-MFC-AGG-ID":"FVa70Fl-MYGSDhRqB053Iw_1775838007","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775838005; x=1776442805;\n h=content-transfer-encoding:in-reply-to:from:content-language\n :references:cc:to:subject:user-agent:mime-version:date:message-id\n :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=17KGi7Zl8vKY2folMPByBKuwGvjFHMjz2nXSyocVZAk=;\n b=DNyp4oeQttHT999wEL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3Hw=","X-Received":["by 2002:ad4:4ea3:0:b0:8aa:a025:78e3 with SMTP id\n 6a1803df08f44-8ac8613a0d8mr56166356d6.6.1775838005563;\n Fri, 10 Apr 2026 09:20:05 -0700 (PDT)","by 2002:ad4:4ea3:0:b0:8aa:a025:78e3 with SMTP id\n 6a1803df08f44-8ac8613a0d8mr56165606d6.6.1775838005003;\n Fri, 10 Apr 2026 09:20:05 -0700 (PDT)"],"Message-ID":"<44f07990-49b4-4836-803d-818700c49ee2@redhat.com>","Date":"Fri, 10 Apr 2026 12:20:03 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++: Include anon enum types in namespace members_of\n [PR124831]","To":"Jakub Jelinek <jakub@redhat.com>, Marek Polacek <polacek@redhat.com>","Cc":"gcc-patches@gcc.gnu.org","References":"<adiqoqSC_hFWRVPJ@tucnak>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<adiqoqSC_hFWRVPJ@tucnak>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"-E_iHSlI9dYbLkFRjFoOmqfJzHhHIyi_YGXPkz-f6Kc_1775838007","X-Mimecast-Originator":"redhat.com","Content-Language":"en-US","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}}]