get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2223666/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2223666,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2223666/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/aeAg83cavdrK6uzd@redhat.com/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/1.1/projects/17/?format=api",
        "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": "<aeAg83cavdrK6uzd@redhat.com>",
    "date": "2026-04-15T23:36:19",
    "name": "[v2] c++/reflection: detect bad splices in class member access [PR124614]",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "cc7c4f89f6d36812f638c9f2253eb6961d8fb577",
    "submitter": {
        "id": 14370,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/14370/?format=api",
        "name": "Marek Polacek",
        "email": "polacek@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/aeAg83cavdrK6uzd@redhat.com/mbox/",
    "series": [
        {
            "id": 500053,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/500053/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500053",
            "date": "2026-04-15T23:36:19",
            "name": "[v2] c++/reflection: detect bad splices in class member access [PR124614]",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/500053/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2223666/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2223666/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=DI5QzTTN;\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=DI5QzTTN",
            "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.133.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 4fwyH348Txz1yHP\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 09:36:58 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DBDB74BA2E3B\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 23:36:55 +0000 (GMT)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 329864BA2E0E\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 23:36:26 +0000 (GMT)",
            "from mail-qk1-f198.google.com (mail-qk1-f198.google.com\n [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-694-8zFef0HzNviUJUwuBK4o8Q-1; Wed, 15 Apr 2026 19:36:24 -0400",
            "by mail-qk1-f198.google.com with SMTP id\n af79cd13be357-8d4adfc84fbso2113919085a.0\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 16:36:24 -0700 (PDT)",
            "from redhat.com ([2603:7000:9500:10::1db4])\n by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8e4f2345c3bsm280805885a.24.2026.04.15.16.36.21\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 15 Apr 2026 16:36:21 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org DBDB74BA2E3B",
            "OpenDKIM Filter v2.11.0 sourceware.org 329864BA2E0E"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 329864BA2E0E",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 329864BA2E0E",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776296186; cv=none;\n b=MbCo58l9TZIm29vpRUA9Ho3/IiXfHzc2CzP/DOkxqFz9Gqu6dAeV63EIb8gYNJoxdF+LmaMNR934ncCWSPyRr/HW3xuHttZV6UK5fIio/ailZaws3oe7/NyNIuP54N6OvyskJ5d5hiAI0oMjXqju5sZKziuBHHAa5AAqqTTEuKk=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776296186; c=relaxed/simple;\n bh=TIb/+lntQ4VpV9QIzUOiDrDYQ9X0YkRTleodc4UJ2sc=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=MWUk+TQK2JyVz0vS2YKSuHZ65s0nOUL4Hr7wj8U+VfKAiaQgTCAQyF0AG3UINFsA9m0x6xkZedXl/fgSJEI/XQ3Bl80o0kXb4/78quwD8cVUB702cr+ymel0KiDRObGjQsR7fo6WNZWyxyeGU7YQfoF7ILhXbqfECWDQdZZ7TIA=",
        "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=1776296185;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n in-reply-to:in-reply-to:references:references;\n bh=xZ4UpIh92SnkyK5od/4rDSx2YoM77Ugf/X7oQdS45tY=;\n b=DI5QzTTNt0ggQcbUvfvzuemXWHC5gGjUTE1AdpiJ0hCJRNUyh6yNJD/MSE2dsIYoZA6qZp\n zvjcXIlZ9cSq98AF/q1ww4fuRfa6e6dl+UMG9TZ9zeg9JvhwgmcXPQHU8mpdhHiE8EKfpV\n oQZO1tH6EiSmESN1mS7ornElSNarbCc=",
        "X-MC-Unique": "8zFef0HzNviUJUwuBK4o8Q-1",
        "X-Mimecast-MFC-AGG-ID": "8zFef0HzNviUJUwuBK4o8Q_1776296184",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776296183; x=1776900983;\n h=user-agent:in-reply-to:content-disposition:mime-version:references\n :message-id:subject:to:from:date:x-gm-gg:x-gm-message-state:from:to\n :cc:subject:date:message-id:reply-to;\n bh=xZ4UpIh92SnkyK5od/4rDSx2YoM77Ugf/X7oQdS45tY=;\n b=YgGZvQmLwkpUNdAVyBgvWHwyQTKuQOdO2xJEFMyBkz8ScgzeMOF9hMfy2YxhAPHU8S\n x3Ao48lkc8m1xPh7bvDz5PSkyJSENk7f8vnWE7znHzOFck98vMV3Smq+I3Yg5rtDzt8Z\n abMSEqAZLDJtWLluInDf9EUyjYct5MAJ6ocgc1a/X5DQd25dRrGIe3SQGmyGOee/gD+p\n vBHylVAHWjVXZjuSlfHPPeA+5Hn4pY8DtehWSAWvafuEol60BWo1AcCOlYxuZUxM51iu\n NkxencmAGyEzDcnbTDduZeZplbclgZT1dXZB33KZMSGD/clWPPwO93uJ3wHtNPOs71ll\n 7Maw==",
        "X-Gm-Message-State": "AOJu0Yz3jt9OeqDi2Dpw7m25AFiIFoAaHMMhZLAy/G7lFqyTKWqftE4h\n CPoHoeJR963+iEYwqRd4LtNm7lQ6hKerXjGa8lS+LWljJLKqQ9bFbe5ih94wmGIeYx8z28UtMUB\n ltibds/BagUeFuGwHi14yfYnYjSzXz66de0vO3M3u0BiI5hc9nF5zjHZqvPhom5Lcs2ZnlCVjYx\n LYc5NoU+qtgi62e/85lSnJqOhTGnkdAgAZjGvkW6+s5Q==",
        "X-Gm-Gg": "AeBDies5MIV/UfvQSoyAPg6tknkKi4Bk4hHdsm0QgCB9G92v0pGNJSMvD8IaRdHst7f\n 8tcPL/2+KYQBqYJo3VBqP54/QUiUs3BCuUll+ugIMr/6nsPvCJjKT9CTioMHiTQU0wgVIbn/bp1\n auIYFJN4+xzq02/1acvkRAxiSntjg8pWpfN+IDCrZnxIfF+E+oaQ+ktJkcqBCP2wgD3FaxWIMLE\n 2KTpUQ4Xdgs2wNHbLurg1F0ek+fYXuedxXhBuYYpeglvivfnlbHJDyaaQ4Fzm8BsRRaaV7qSr7c\n TrRK1k1DdmqVcMzImnIgoudlhzQ2sMPLQt4FT3RCja15/ciiwKmQlPVzuNyRWWjs8LBt6LTBPFp\n cLw==",
        "X-Received": [
            "by 2002:a05:620a:2589:b0:8c5:3869:3f2e with SMTP id\n af79cd13be357-8ddcf5b34ecmr3443468085a.42.1776296182819;\n Wed, 15 Apr 2026 16:36:22 -0700 (PDT)",
            "by 2002:a05:620a:2589:b0:8c5:3869:3f2e with SMTP id\n af79cd13be357-8ddcf5b34ecmr3443462385a.42.1776296182180;\n Wed, 15 Apr 2026 16:36:22 -0700 (PDT)"
        ],
        "Date": "Wed, 15 Apr 2026 19:36:19 -0400",
        "From": "Marek Polacek <polacek@redhat.com>",
        "To": "GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>,\n Jakub Jelinek <jakub@redhat.com>",
        "Subject": "[PATCH v2] c++/reflection: detect bad splices in class member access\n [PR124614]",
        "Message-ID": "<aeAg83cavdrK6uzd@redhat.com>",
        "References": "<20260415224602.1507107-1-polacek@redhat.com>",
        "MIME-Version": "1.0",
        "In-Reply-To": "<20260415224602.1507107-1-polacek@redhat.com>",
        "User-Agent": "Mutt/2.3.1 (2026-03-20)",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-MFC-PROC-ID": "Eox77jf5VqOmqNCI75UnCJrygDZFGWfPCgyAase723w_1776296184",
        "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>",
        "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"
    },
    "content": "Update: we can use valid_splice_for_member_access_p also in\ncp_parser_splice_expression.  It doesn't cover the SPLICE_EXPR\ncheck but that was unreachable anyway due to the dependent_splice_p\ncheck above.\n\nBootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?\n\n-- >8 --\nThis testcase shows that we still don't detect some invalid splices\nused in a class member access.  E.g. in,\n\n  b.[:reflect_constant (^^B::id):];\n\nthe splice designates a reflection which cannot be used in obj.[:R:].\nWe can enhance check_splice_expr to check for exactly those codes\nthat can be handled.  This is also an opportunity to finally factor\nour the long splice_p checks into a helper.\n\nIt can also be something like\n\n  b.[:reflect_constant (data_member_spec (^^int, { .name = \"i\" })):];\n\nwhere we don't correctly print the RHS, thus the dump_data_member_spec\naddition.\n\n\tPR c++/124614\n\ngcc/cp/ChangeLog:\n\n\t* cp-tree.h (valid_splice_for_member_access_p): Declare.\n\t(dump_data_member_spec): Declare.\n\t* error.cc (dump_expr) <case REFLECT_EXPR>: Print a data member\n\tdescription.\n\t* parser.cc (cp_parser_splice_expression): Use\n\tvalid_splice_for_member_access_p.\n\t* pt.cc (tsubst_splice_expr): Likewise.\n\t* reflect.cc (dump_data_member_spec): New.\n\t(eval_display_string_of): Use it.\n\t(valid_splice_for_member_access_p): New.\n\t(check_splice_expr): Check that we got\n\tvalid_splice_for_member_access_p for a member access.\n\t* typeck.cc (finish_class_member_access_expr): Use\n\tvalid_splice_for_member_access_p.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/reflect/member23.C: New test.\n---\n gcc/cp/cp-tree.h                        |  3 ++\n gcc/cp/error.cc                         |  7 ++++\n gcc/cp/parser.cc                        | 11 +----\n gcc/cp/pt.cc                            | 10 +----\n gcc/cp/reflect.cc                       | 56 ++++++++++++++++++++-----\n gcc/cp/typeck.cc                        | 24 ++---------\n gcc/testsuite/g++.dg/reflect/member23.C | 24 +++++++++++\n 7 files changed, 85 insertions(+), 50 deletions(-)\n create mode 100644 gcc/testsuite/g++.dg/reflect/member23.C\n\n\nbase-commit: 77d4080e1e5f9d467816e2e2e878edbfbb7ee1c1",
    "diff": "diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h\nindex c5a3a6bd39b..47e4dd27e90 100644\n--- a/gcc/cp/cp-tree.h\n+++ b/gcc/cp/cp-tree.h\n@@ -9436,6 +9436,8 @@ extern bool consteval_only_p (tree) ATTRIBUTE_PURE;\n extern bool compare_reflections (tree, tree) ATTRIBUTE_PURE;\n extern bool valid_splice_type_p (const_tree) ATTRIBUTE_PURE;\n extern bool valid_splice_scope_p (const_tree) ATTRIBUTE_PURE;\n+extern bool valid_splice_for_member_access_p (const_tree, bool = true)\n+  ATTRIBUTE_PURE;\n extern bool check_splice_expr (location_t, location_t, tree, bool, bool, bool,\n \t\t\t       bool, bool) ATTRIBUTE_PURE;\n extern tree make_splice_scope (tree, bool);\n@@ -9443,6 +9445,7 @@ extern bool dependent_splice_p (const_tree) ATTRIBUTE_PURE;\n extern tree reflection_mangle_prefix (tree, char [3]);\n extern void check_consteval_only_fn (tree);\n extern bool reflection_function_template_p (tree) ATTRIBUTE_PURE;\n+extern void dump_data_member_spec (pretty_printer *, tree);\n \n /* Inline bodies.  */\n \ndiff --git a/gcc/cp/error.cc b/gcc/cp/error.cc\nindex b3e66924e31..e7121dc1017 100644\n--- a/gcc/cp/error.cc\n+++ b/gcc/cp/error.cc\n@@ -3337,6 +3337,13 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)\n \t  dump_decl (pp, h, flags);\n \telse if (TYPE_P (h))\n \t  dump_type (pp, h, flags);\n+\telse if (TREE_CODE (h) == TREE_VEC)\n+\t  {\n+\t    pp_format_decoder (pp) = cp_printer;\n+\t    pp->set_format_postprocessor\n+\t      (std::make_unique<cxx_format_postprocessor> ());\n+\t    dump_data_member_spec (pp, h);\n+\t  }\n \telse\n \t  dump_expr (pp, h, flags);\n \tbreak;\ndiff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc\nindex 742cfd03621..d5f508b7e19 100644\n--- a/gcc/cp/parser.cc\n+++ b/gcc/cp/parser.cc\n@@ -6355,16 +6355,7 @@ cp_parser_splice_expression (cp_parser *parser, bool template_p,\n     {\n       /* Grab the unresolved expression then.  */\n       t = unresolved;\n-      gcc_assert (TREE_CODE (t) == FIELD_DECL\n-\t\t  || VAR_P (t)\n-\t\t  || TREE_CODE (t) == CONST_DECL\n-\t\t  || TREE_CODE (t) == FUNCTION_DECL\n-\t\t  || DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (t))\n-\t\t  || variable_template_p (t)\n-\t\t  || BASELINK_P (t)\n-\t\t  || TREE_CODE (t) == SPLICE_EXPR\n-\t\t  || TREE_CODE (t) == TEMPLATE_ID_EXPR\n-\t\t  || TREE_CODE (t) == TREE_BINFO);\n+      gcc_assert (valid_splice_for_member_access_p (t, /*decls_only_p=*/false));\n       /* ??? We're not setting *idk here.  */\n     }\n   else if (address_p\ndiff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc\nindex 6fb26cd9777..2828f87f12a 100644\n--- a/gcc/cp/pt.cc\n+++ b/gcc/cp/pt.cc\n@@ -16969,15 +16969,7 @@ tsubst_splice_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)\n      cp_parser_postfix_dot_deref_expression wants to see only\n      certain kind of entities.  */\n   if (SPLICE_EXPR_MEMBER_ACCESS_P (t))\n-    gcc_assert (TREE_CODE (op) == FIELD_DECL\n-\t\t|| VAR_P (op)\n-\t\t|| TREE_CODE (op) == CONST_DECL\n-\t\t|| TREE_CODE (op) == FUNCTION_DECL\n-\t\t|| DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (op))\n-\t\t|| variable_template_p (op)\n-\t\t|| BASELINK_P (op)\n-\t\t|| TREE_CODE (op) == TEMPLATE_ID_EXPR\n-\t\t|| TREE_CODE (op) == TREE_BINFO);\n+    gcc_assert (valid_splice_for_member_access_p (op, /*decls_only_p=*/false));\n \n   return op;\n }\ndiff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc\nindex f06353305a5..2b7e7033953 100644\n--- a/gcc/cp/reflect.cc\n+++ b/gcc/cp/reflect.cc\n@@ -3679,6 +3679,21 @@ eval_identifier_of (location_t loc, const constexpr_ctx *ctx, tree r,\n   return build_cplus_new (ret_type, ret, tf_warning_or_error);\n }\n \n+/* Display R, which is a data member description.  */\n+\n+void\n+dump_data_member_spec (pretty_printer *pp, tree r)\n+{\n+  pp_printf (pp, \"(%T, %E, %E, %E, %s, {\", TREE_VEC_ELT (r, 0),\n+\t     TREE_VEC_ELT (r, 1), TREE_VEC_ELT (r, 2), TREE_VEC_ELT (r, 3),\n+\t     TREE_VEC_ELT (r, 4) == boolean_true_node\n+\t     ? \"true\" : \"false\");\n+  for (int i = 5; i < TREE_VEC_LENGTH (r); ++i)\n+    pp_printf (pp, \"%s%E\", i == 5 ? \"\" : \", \",\n+\t       REFLECT_EXPR_HANDLE (TREE_VEC_ELT (r, i)));\n+  pp_printf (pp, \"})\");\n+}\n+\n /* Process std::meta::{,u8}display_string_of.\n    Returns: An implementation-defined string_view or u8string_view,\n    respectively.\n@@ -3738,16 +3753,7 @@ eval_display_string_of (location_t loc, const constexpr_ctx *ctx, tree r,\n       pp_printf (&pp, \"%T: %T\", d, BINFO_TYPE (r));\n     }\n   else if (kind == REFLECT_DATA_MEMBER_SPEC)\n-    {\n-      pp_printf (&pp, \"(%T, %E, %E, %E, %s, {\", TREE_VEC_ELT (r, 0),\n-\t\t TREE_VEC_ELT (r, 1), TREE_VEC_ELT (r, 2), TREE_VEC_ELT (r, 3),\n-\t\t TREE_VEC_ELT (r, 4) == boolean_true_node\n-\t\t ? \"true\" : \"false\");\n-      for (int i = 5; i < TREE_VEC_LENGTH (r); ++i)\n-\tpp_printf (&pp, \"%s%E\", i == 5 ? \"\" : \", \",\n-\t\t   REFLECT_EXPR_HANDLE (TREE_VEC_ELT (r, i)));\n-      pp_printf (&pp, \"})\");\n-    }\n+    dump_data_member_spec (&pp, r);\n   else if (eval_is_annotation (r, kind) == boolean_true_node)\n     pp_printf (&pp, \"[[=%E]]\",\n \t       tree_strip_any_location_wrapper (TREE_VALUE (TREE_VALUE (r))));\n@@ -8874,6 +8880,28 @@ valid_splice_scope_p (const_tree t)\n \t  || TREE_CODE (t) == NAMESPACE_DECL);\n }\n \n+/* Return true if T is a valid result of the splice in a class member access,\n+   as in obj.[:R:].  If DECLS_ONLY_P, only certain decls are OK.  */\n+\n+bool\n+valid_splice_for_member_access_p (const_tree t, bool decls_only_p/*=true*/)\n+{\n+  if (TREE_CODE (t) == FIELD_DECL\n+      || VAR_P (t)\n+      || TREE_CODE (t) == CONST_DECL\n+      || TREE_CODE (t) == FUNCTION_DECL\n+      || DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (const_cast<tree> (t)))\n+      || variable_template_p (const_cast<tree> (t)))\n+    return true;\n+\n+  if (decls_only_p)\n+    return false;\n+\n+  return (BASELINK_P (t)\n+\t  || TREE_CODE (t) == TEMPLATE_ID_EXPR\n+\t  || TREE_CODE (t) == TREE_BINFO);\n+}\n+\n /* Check a function DECL for CWG 3115: Every function of consteval-only\n    type shall be an immediate function.  */\n \n@@ -8974,6 +9002,14 @@ check_splice_expr (location_t loc, location_t start_loc, tree t,\n       return false;\n     }\n \n+  if (member_access_p\n+      && !valid_splice_for_member_access_p (t, /*decls_only_p=*/false))\n+    {\n+      if (complain_p)\n+\terror_at (loc, \"cannot use %qE to access a class member\", t);\n+      return false;\n+    }\n+\n   /* [expr.unary.op]/3.1 \"If the operand [of unary &] is a qualified-id or\n      splice-expression designating a non-static member m, other than an\n      explicit object member function, m shall be a direct member of some\ndiff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc\nindex c241721832c..dcc35ae28a2 100644\n--- a/gcc/cp/typeck.cc\n+++ b/gcc/cp/typeck.cc\n@@ -3594,13 +3594,7 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p,\n \t      return error_mark_node;\n \t    }\n \t}\n-      else if (splice_p\n-\t       && (TREE_CODE (name) == FIELD_DECL\n-\t\t   || VAR_P (name)\n-\t\t   || TREE_CODE (name) == CONST_DECL\n-\t\t   || TREE_CODE (name) == FUNCTION_DECL\n-\t\t   || DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (name))\n-\t\t   || variable_template_p (name)))\n+      else if (splice_p && valid_splice_for_member_access_p (name))\n \t{\n \t  scope = context_for_name_lookup (OVL_FIRST (name));\n \t  if (!CLASS_TYPE_P (scope))\n@@ -3664,14 +3658,7 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p,\n \t  gcc_assert (CLASS_TYPE_P (scope));\n \t  gcc_assert (identifier_p (name)\n \t\t      || TREE_CODE (name) == BIT_NOT_EXPR\n-\t\t      || (splice_p\n-\t\t\t  && (TREE_CODE (name) == FIELD_DECL\n-\t\t\t      || VAR_P (name)\n-\t\t\t      || TREE_CODE (name) == CONST_DECL\n-\t\t\t      || TREE_CODE (name) == FUNCTION_DECL\n-\t\t\t      || DECL_FUNCTION_TEMPLATE_P\n-\t\t\t\t\t\t(OVL_FIRST (name))\n-\t\t\t      || variable_template_p (name))));\n+\t\t      || (splice_p && valid_splice_for_member_access_p (name)));\n \n \t  if (constructor_name_p (name, scope))\n \t    {\n@@ -3723,12 +3710,7 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p,\n \t    goto dependent;\n \t  member = lookup_destructor (object, scope, name, complain);\n \t}\n-      else if (splice_p && (TREE_CODE (name) == FIELD_DECL\n-\t\t\t    || VAR_P (name)\n-\t\t\t    || TREE_CODE (name) == CONST_DECL\n-\t\t\t    || TREE_CODE (name) == FUNCTION_DECL\n-\t\t\t    || DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (name))\n-\t\t\t    || variable_template_p (name)))\n+      else if (splice_p && valid_splice_for_member_access_p (name))\n \t{\n \t  member = name;\n \t  name = OVL_FIRST (name);\ndiff --git a/gcc/testsuite/g++.dg/reflect/member23.C b/gcc/testsuite/g++.dg/reflect/member23.C\nnew file mode 100644\nindex 00000000000..e38d70e38ef\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/member23.C\n@@ -0,0 +1,24 @@\n+// PR c++/124614\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+using namespace std::meta;\n+\n+struct B { int id; };\n+\n+void\n+f (int p)\n+{\n+  B b;\n+  b.[:reflect_constant (^^B::id):]; // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (&B::id):];  // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (data_member_spec (^^int, { .name = \"i\" })):]; // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (false):];   // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (42):];\t    // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (3.14f):];   // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (&::f):];    // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (^^::):];    // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (info{}):];  // { dg-error \"access a class member\" }\n+  b.[:reflect_constant (^^p):];\t    // { dg-error \"access a class member\" }\n+}\n",
    "prefixes": [
        "v2"
    ]
}