Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2224003/?format=api
{ "id": 2224003, "url": "http://patchwork.ozlabs.org/api/patches/2224003/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/aeDomvgfcUnzz1XG@tucnak/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/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, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<aeDomvgfcUnzz1XG@tucnak>", "list_archive_url": null, "date": "2026-04-16T13:48:10", "name": "c++, v2: Reject splicing of function parameters [PR123783]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "87804b94ecd00a49cad57972658dc3a5f779f132", "submitter": { "id": 671, "url": "http://patchwork.ozlabs.org/api/people/671/?format=api", "name": "Jakub Jelinek", "email": "jakub@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/aeDomvgfcUnzz1XG@tucnak/mbox/", "series": [ { "id": 500167, "url": "http://patchwork.ozlabs.org/api/series/500167/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500167", "date": "2026-04-16T13:48:10", "name": "c++, v2: Reject splicing of function parameters [PR123783]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500167/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2224003/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2224003/checks/", "tags": {}, "related": [], "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=dOPBaq0u;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.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=dOPBaq0u", "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 [38.145.34.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 4fxK9b0ymLz1yG9\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 23:48:51 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 4D1A64BA23F2\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 13:48:49 +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 E36404BA23F9\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 13:48:16 +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-16-9xIg3DZPOO-KNzQSyNcWVw-1; Thu,\n 16 Apr 2026 09:48:15 -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 592D218004AD\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 13:48:14 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.44.33.129])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id A6D48180047F; Thu, 16 Apr 2026 13:48:13 +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 63GDmAki1124356\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Thu, 16 Apr 2026 15:48:11 +0200", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63GDmAmX1124355;\n Thu, 16 Apr 2026 15:48:10 +0200" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 4D1A64BA23F2", "OpenDKIM Filter v2.11.0 sourceware.org E36404BA23F9" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org E36404BA23F9", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org E36404BA23F9", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776347297; cv=none;\n b=mr809YKsrfPG4zuO55L6CRs7c2EdFiwkGTz6iwPjuKYNXgAEj6KNFRJF/JHibGbS7d2Um1c24lrN3FMMUUa16261sLIGG6cu9WHBfmdRrQ/wDWlfpbWgPIjdFcMNSffXGhiivASFv9th/CTacwglk8wFy8hEHzO1TEWt/7rbj90=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776347297; c=relaxed/simple;\n bh=rBAn9p7Qmaj5hGvxjOeojwxGwKK2DGxKTU229rGwIBM=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=XTI8tbzdowjeIvU9pYwnSJ42bRf6ySqAFHonsJ9VTTwstcayjV1dTnEHRr2ORu2/a8v76Cm+uExC7RxYo0XygWzfpWDaGb3Amkr8JpzhzLvQl28qxjeemuaXLy34XDcFfdoGtKGIhoiB4g+oYAqGphAxFvgxLsL76m1xWBLqNok=", "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=1776347296;\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:in-reply-to:in-reply-to: references:references;\n bh=HwkDtwq8Kho7+Bad9Qz9GmuKrg7cwcbXNFO3VW6eOpA=;\n b=dOPBaq0upQjk0aKDi7xWB27y505qkx0sFWQOCgEcdl/PbgRRXUKjKcItZep7ckSQ/WXfRv\n Gq6ahHt7KEDAbEFwpDe9I8CxxotEwkoFHoLTZgTP2PHMmQsIN59XDvnhIPD1AZCfuK0vjv\n DcAQGLQk2a+AsfjNRza+li8encLASg8=", "X-MC-Unique": "9xIg3DZPOO-KNzQSyNcWVw-1", "X-Mimecast-MFC-AGG-ID": "9xIg3DZPOO-KNzQSyNcWVw_1776347294", "Date": "Thu, 16 Apr 2026 15:48:10 +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++, v2: Reject splicing of function parameters [PR123783]", "Message-ID": "<aeDomvgfcUnzz1XG@tucnak>", "References": "<aeC5t2bY4NkoD4nm@tucnak>\n <aeDj7wrH60HjsnPU@redhat.com>", "MIME-Version": "1.0", "In-Reply-To": "<aeDj7wrH60HjsnPU@redhat.com>", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "3i8OslHD9cFdGtbzSih5o1OAta-bkjabIHYYXLIVa_I_1776347294", "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": "On Thu, Apr 16, 2026 at 09:28:15AM -0400, Marek Polacek wrote:\n> Looks ok. Optionally: \n> - add a comment saying why this isn't in check_splice_expr\n> - we could also have a location_t for the cp_expr_loc_or_input_loc\n> since it's used 3x in the function now\n> - could add %qD in the error message since that's what check_splice_expr\n> does\n\nThis patch incorporates those 3 changes.\n\nThough unsure if the loc change is desirable, perhaps it should be done only\ninside of the REFLECT_PARM if (the normal case is no diagnostics).\n\n2026-04-16 Jakub Jelinek <jakub@redhat.com>\n\n\tPR c++/123783\n\t* reflect.cc (splice): Reject splicing of function parameters.\n\n\t* g++.dg/reflect/mangle3.C: Remove f5<parameters_of (^^g)[0]>()\n\tcase.\n\t* g++.dg/reflect/dep14.C: Include <ranges>.\n\t(func): Apply variable_of to each vector member.\n\t(func2): Likewise. Use ^^func2 instead of ^^func.\n\t* g++.dg/reflect/splice12.C: New test.\n\n\n\n\tJakub", "diff": "--- gcc/cp/reflect.cc.jj\t2026-04-16 15:17:56.980684094 +0200\n+++ gcc/cp/reflect.cc\t2026-04-16 15:35:02.392552721 +0200\n@@ -8503,13 +8503,28 @@ splice (tree refl)\n gcc_checking_assert (seen_error ());\n return error_mark_node;\n }\n+ location_t loc = cp_expr_loc_or_input_loc (refl);\n if (!REFLECT_EXPR_P (refl))\n {\n- error_at (cp_expr_loc_or_input_loc (refl), \"splice argument must be an \"\n+ error_at (loc, \"splice argument must be an \"\n \t\t\"expression of type %qs\", \"std::meta::info\");\n return error_mark_node;\n }\n \n+ /* This isn't checked in check_splice_expr, because reflect_kind isn't\n+ available there and variable_of (parameters_of (...)[...]) can be\n+ spliced. */\n+ if (REFLECT_EXPR_KIND (refl) == REFLECT_PARM)\n+ {\n+ auto_diagnostic_group d;\n+ error_at (loc, \"cannot use %qD function parameter reflection in a \"\n+\t\t\"splice expression\", REFLECT_EXPR_HANDLE (refl));\n+ if (DECL_CONTEXT (REFLECT_EXPR_HANDLE (refl)) == current_function_decl)\n+\tinform (loc,\n+\t\t\"apply %<std::meta::variable_of%> on it before splicing\");\n+ return error_mark_node;\n+ }\n+\n /* We are bringing some entity from the unevaluated expressions world\n to possibly outside of that, mark it used. */\n if (!mark_used (REFLECT_EXPR_HANDLE (refl)))\n--- gcc/testsuite/g++.dg/reflect/mangle3.C.jj\t2026-04-16 15:17:56.980684094 +0200\n+++ gcc/testsuite/g++.dg/reflect/mangle3.C\t2026-04-16 15:31:27.989860878 +0200\n@@ -175,8 +175,6 @@ g (int p)\n // { dg-final { scan-assembler \"_Z2f5ILDmvlLi42EEEDtDST_EEv\" } }\n f5<std::meta::reflect_object (arr[1])>();\n // { dg-final { scan-assembler \"_Z2f5ILDmobixL_Z3arrEL\\[ilx]1EEEDtDST_EEv\" } }\n- f5<parameters_of (^^g)[0]>();\n-// { dg-final { scan-assembler \"_Z2f5ILDmpa_1giEEDtDST_EEv\" } }\n f5<bases_of (^^S, ctx)[0]>();\n // { dg-final { scan-assembler \"_Z2f5ILDmba_1SEEDtDST_EEv\" } }\n f6<Y>(Y{42});\n--- gcc/testsuite/g++.dg/reflect/dep14.C.jj\t2026-04-16 15:17:56.980684094 +0200\n+++ gcc/testsuite/g++.dg/reflect/dep14.C\t2026-04-16 15:31:27.990020066 +0200\n@@ -3,6 +3,7 @@\n // { dg-additional-options \"-freflection\" }\n \n #include <meta>\n+#include <ranges>\n \n namespace __impl {\n template<auto... vals>\n@@ -30,7 +31,7 @@ int func(int counter, float factor) {\n std::array<void *, parameters_of(^^func).size()> args;\n \n std::size_t i = 0;\n- [:expand(parameters_of(^^func)):] >> [&i, &counter, &factor, &args]<auto e>\n+ [:expand(parameters_of(^^func) | std::views::transform(std::meta::variable_of)):] >> [&i, &counter, &factor, &args]<auto e>\n {\n args[i++] = &[:e:]; // { dg-error \"use of local variable\" }\n };\n@@ -38,10 +39,10 @@ int func(int counter, float factor) {\n }\n \n int func2(int counter, float factor) {\n- std::array<void *, parameters_of(^^func).size()> args;\n+ std::array<void *, parameters_of(^^func2).size()> args;\n \n std::size_t i = 0;\n- [:expand(parameters_of(^^func)):] >> [&]<auto e>\n+ [:expand(parameters_of(^^func2) | std::views::transform(std::meta::variable_of)):] >> [&]<auto e>\n {\n args[i++] = &[:e:]; // { dg-error \"use of local variable|trying to capture \\[^\\n\\r]* in instantiation of generic lambda\" }\n };\n--- gcc/testsuite/g++.dg/reflect/splice12.C.jj\t2026-04-16 15:31:27.990111825 +0200\n+++ gcc/testsuite/g++.dg/reflect/splice12.C\t2026-04-16 15:34:49.937761087 +0200\n@@ -0,0 +1,21 @@\n+// PR c++/123783\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+\n+void\n+bar (int a)\n+{\n+}\n+\n+void\n+foo (int a)\n+{\n+ auto b = &[: ^^a :];\n+ auto c = &[: variable_of (parameters_of (^^foo)[0]) :];\n+ auto d = &[: parameters_of (^^foo)[0] :];\t\t\t// { dg-error \"cannot use 'a' function parameter reflection in a splice expression\" }\n+\t\t\t\t\t\t\t\t// { dg-message \"apply 'std::meta::variable_of' on it before splicing\" \"\" { target *-*-* } .-1 }\n+ auto e = &[: parameters_of (^^bar)[0] :];\t\t\t// { dg-error \"cannot use 'a' function parameter reflection in a splice expression\" }\n+ auto f = [] { auto g = &[: parameters_of (^^foo)[0] :]; };\t// { dg-error \"cannot use 'a' function parameter reflection in a splice expression\" }\n+}\n", "prefixes": [] }