{"id":2221728,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221728/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/adiqoqSC_hFWRVPJ@tucnak/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<adiqoqSC_hFWRVPJ@tucnak>","date":"2026-04-10T07:45:38","name":"c++: Include anon enum types in namespace members_of [PR124831]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e31da58c4045f4acadad22c1753ee0d01b5b9e8e","submitter":{"id":671,"url":"http://patchwork.ozlabs.org/api/1.1/people/671/?format=json","name":"Jakub Jelinek","email":"jakub@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/adiqoqSC_hFWRVPJ@tucnak/mbox/","series":[{"id":499418,"url":"http://patchwork.ozlabs.org/api/1.1/series/499418/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499418","date":"2026-04-10T07:45:38","name":"c++: Include anon enum types in namespace members_of [PR124831]","version":1,"mbox":"http://patchwork.ozlabs.org/series/499418/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221728/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221728/checks/","tags":{},"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=N8FML4fr;\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=N8FML4fr","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 4fsTQ44CnCz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 17:46:19 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 405464BA2E18\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 07:46:17 +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 0BF154BA2E10\n for <gcc-patches@gcc.gnu.org>; Fri, 10 Apr 2026 07:45:48 +0000 (GMT)","from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-Whx-gB0FMbOhr88hMu_RAg-1; Fri,\n 10 Apr 2026 03:45:46 -0400","from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id DCD14180AC40\n for <gcc-patches@gcc.gnu.org>; Fri, 10 Apr 2026 07:45:42 +0000 (UTC)","from tucnak.zalov.cz (unknown [10.44.33.241])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 30671180036E; Fri, 10 Apr 2026 07:45:41 +0000 (UTC)","from tucnak.zalov.cz (localhost [127.0.0.1])\n by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 63A7jdLa3927148\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Fri, 10 Apr 2026 09:45:39 +0200","(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63A7jdjw3927147;\n Fri, 10 Apr 2026 09:45:39 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 405464BA2E18","OpenDKIM Filter v2.11.0 sourceware.org 0BF154BA2E10"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 0BF154BA2E10","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 0BF154BA2E10","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775807148; cv=none;\n b=mMGfny8qei8jlBpDPnP7ErTXgU9r74Zn8NT0yAK0VrFlI9yn/jzG4DLghCEF+j/Ti+8KB7zt4wHWhaPWeCckUroaKyv1Zlhnn/hMUeXL5i5w7rfv8NRSRy+gYeRp1NoigR0OelnugBlMLs0jb5v4S71/FdDd1QiUiuD6DYqDrtg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775807148; c=relaxed/simple;\n bh=4g86BW6LjsJ98mL0Fw+N+dp9WFArinUfG2/5ABGFj9c=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=ZfpiTyP2gjUQwIzrF/KMrNyi3xRY2ZkUQPnKnClqcmPwhhHUIqfm3U/2wWCaOkks4DwIdlZnNkY354PTxlT6B0AChWvb6ix8FaOB2MHY9ODDTTfM1vgVL3EOeLWpZGfnmjB1ksFZA95onlQuvHLMcFIGMT+HWaKBrdARNJ2IkzA=","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=1775807147;\n h=from:from:reply-to:reply-to:subject:subject:date:date:\n message-id:message-id:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=xdmMsnGKx2dzQK3g60JaCy9YGPXr57urp8M3w9wjayQ=;\n b=N8FML4frKOHnFowd9Gc83qunv1W9E4qeHF4Sj8TEkjbPFqYkry4BZzTTMpjOys+UeUfeSB\n mfqbvChUoMj9tc/xHOpNBh2fXtLEaB/CUnK+8A76xPxBTjYgM1S98fBwQxZPqnoHw9clj0\n SU6MkotQ+Ze2vHZ/hTAbgQMcBnL7K5Q=","X-MC-Unique":"Whx-gB0FMbOhr88hMu_RAg-1","X-Mimecast-MFC-AGG-ID":"Whx-gB0FMbOhr88hMu_RAg_1775807145","Date":"Fri, 10 Apr 2026 09:45:38 +0200","From":"Jakub Jelinek <jakub@redhat.com>","To":"Jason Merrill <jason@redhat.com>, Marek Polacek <polacek@redhat.com>","Cc":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] c++: Include anon enum types in namespace members_of\n [PR124831]","Message-ID":"<adiqoqSC_hFWRVPJ@tucnak>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.93","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"kQebO9D_fdtbEyPzcf3AqRBeYKTH_Nah_EgoGZVP8Aw_1775807145","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","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>","Reply-To":"Jakub Jelinek <jakub@redhat.com>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Hi!\n\nAs the testcase shows, we have similar problem with namespace scope\nanonymous enums like we have with namespace scope anonymous unions.\nBecause they are anonymous, in neither case we emit anything into the\nnamespace bindings but we should still list those.\nNow, for anonymous union this is done by adding it (once only) when\nseeing corresponding DECL_ANON_UNION_VAR_P (and it doesn't work when there\nis anon union without any members but that is a pedwarn anyway).\n\nThe following patch handles it similarly for anon enums, namespace scope\nenum {}; is still ignored (but that is a pedwarn as well, so not a big deal)\nand when there is at least one enumerator in it, we add it when seeing\nthe CONST_DECL (but again, just once for the whole members_of call).\n\nBootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?\n\n2026-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\n\tJakub","diff":"--- 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+\t  tree type = CP_DECL_CONTEXT (b);\n+\t  if (!data->seen)\n+\t    data->seen = new hash_set<tree>;\n+\t  if (!data->seen->add (type))\n+\t    {\n+\t      CONSTRUCTOR_APPEND_ELT (data->elts, NULL_TREE,\n+\t\t\t\t      get_reflection_raw (data->loc, type));\n+\t      return;\n+\t    }\n+\t}\n+\n       if (TREE_CODE (b) == TYPE_DECL)\n \tm = TREE_TYPE (b);\n \n--- gcc/testsuite/g++.dg/reflect/members_of13.C.jj\t2026-04-09 15:45:44.788055664 +0200\n+++ gcc/testsuite/g++.dg/reflect/members_of13.C\t2026-04-09 16:12:01.943097471 +0200\n@@ -0,0 +1,31 @@\n+// PR c++/124831\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+\n+namespace N\n+{\n+  enum { A, B, C };\n+  enum { D };\n+  enum { E, F, G, H, I };\n+}\n+\n+namespace O\n+{\n+  typedef enum { A, B, C } J;\n+  typedef enum { D } K;\n+  typedef enum { E, F, G, H, I } L;\n+}\n+\n+static_assert (members_of (^^N, std::meta::access_context::current ()).size () == 3);\n+static_assert (enumerators_of (members_of (^^N, std::meta::access_context::current ())[0])[0] == ^^N::A\n+\t       || enumerators_of (members_of (^^N, std::meta::access_context::current ())[1])[0] == ^^N::A\n+\t       || enumerators_of (members_of (^^N, std::meta::access_context::current ())[2])[0] == ^^N::A);\n+static_assert (enumerators_of (members_of (^^N, std::meta::access_context::current ())[0])[0] == ^^N::D\n+\t       || enumerators_of (members_of (^^N, std::meta::access_context::current ())[1])[0] == ^^N::D\n+\t       || enumerators_of (members_of (^^N, std::meta::access_context::current ())[2])[0] == ^^N::D);\n+static_assert (enumerators_of (members_of (^^N, std::meta::access_context::current ())[0])[0] == ^^N::E\n+\t       || enumerators_of (members_of (^^N, std::meta::access_context::current ())[1])[0] == ^^N::E\n+\t       || enumerators_of (members_of (^^N, std::meta::access_context::current ())[2])[0] == ^^N::E);\n+static_assert (members_of (^^O, std::meta::access_context::current ()).size () == 6);\n","prefixes":[]}