{"id":2219846,"url":"http://patchwork.ozlabs.org/api/patches/2219846/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/CANeSxVxSyDXvVgw6-F508k5YYvjsdZEoo+Ur=YPvEJ1OKs4=gw@mail.gmail.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<CANeSxVxSyDXvVgw6-F508k5YYvjsdZEoo+Ur=YPvEJ1OKs4=gw@mail.gmail.com>","list_archive_url":null,"date":"2026-04-04T21:38:04","name":"libstdc++: Allow for function parameters in annotations_of[_with_type] [P3795R2]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7520564c883562892c5eb1b13488e59e443fb725","submitter":{"id":93056,"url":"http://patchwork.ozlabs.org/api/people/93056/?format=json","name":"Septicake","email":"septicake056@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/CANeSxVxSyDXvVgw6-F508k5YYvjsdZEoo+Ur=YPvEJ1OKs4=gw@mail.gmail.com/mbox/","series":[{"id":498750,"url":"http://patchwork.ozlabs.org/api/series/498750/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=498750","date":"2026-04-04T21:38:04","name":"libstdc++: Allow for function parameters in annotations_of[_with_type] [P3795R2]","version":1,"mbox":"http://patchwork.ozlabs.org/series/498750/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219846/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219846/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=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=GeTEAgkX;\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=fail reason=\"signature verification failed\" (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=GeTEAgkX","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","sourceware.org; spf=pass smtp.mailfrom=gmail.com","server2.sourceware.org;\n arc=pass smtp.remote-ip=209.85.217.48"],"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 4fp89Y2FkBz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 07:38:54 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id EA6A34BA23D3\n\tfor <incoming@patchwork.ozlabs.org>; Sat,  4 Apr 2026 21:38:50 +0000 (GMT)","from mail-vs1-f48.google.com (mail-vs1-f48.google.com\n [209.85.217.48])\n by sourceware.org (Postfix) with ESMTPS id A62534BA2E2B\n for <gcc-patches@gcc.gnu.org>; Sat,  4 Apr 2026 21:38:16 +0000 (GMT)","by mail-vs1-f48.google.com with SMTP id\n ada2fe7eead31-60591ade110so1939303137.1\n for <gcc-patches@gcc.gnu.org>; Sat, 04 Apr 2026 14:38:16 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org EA6A34BA23D3","OpenDKIM Filter v2.11.0 sourceware.org A62534BA2E2B"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org A62534BA2E2B","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org A62534BA2E2B","ARC-Seal":["i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1775338696; cv=pass;\n b=Cfr24UZGHQwrSByPuJ4MYLDPgpI3pj9PD5xJNuMCnuM3HUCVMJEqAHf99rDF5vzF2cpdv9cryIGFc4v5g+Md2SDb54RGQbOcaYAaKxVow/9bW3ccGradBvprRnCmlmHqEv6wO9xzNPWQa7sAN3gUYxE7jPCCF52XPRNop0Kh0sM=","i=1; a=rsa-sha256; t=1775338696; cv=none;\n d=google.com; s=arc-20240605;\n b=WR8NozBZRGrRRLEK8eMcIa4NCOXM6Uc7YlstVFSU/BjhDIWFelus7gi+BvhQgn4s2H\n DoNFISAmjeFibfOeyQ9h2AVjqhZRZFfhlUFIDJAy3VU2Yx1t6Vyw0GssLEcovyjGqBge\n VV91SnZhw7Jci6LACkwn/hrW/0cQw9fkffoFsRjF4oFolilTkXJM+AOswxZi91wRHqjZ\n bJ6lDFL18cBDCBPEFkm9aQSKAwNF6XmXGQWPEsousJnegx0c3F5pkFhUJca1H70Nx2yn\n D9kXLUGygS9a6sj3ZSxhMGe2MLT2RLhom7gq4PPR0QXVLA7yS3hRQhKZwFeoOLE0w7FL\n Zj4g=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775338696; c=relaxed/simple;\n bh=nN8zFhKGMxInW5KzWEDFA1tKGUydYZLPtzB3j0jS8gc=;\n h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;\n b=x1F8mctfws+fJxGZIAbfuqgPqXZJjWBRTlfT7RSpIjE4GQxJ8fCzcJd/Pm8bB+Ru7NYYN/PZ+FZTPUJPamK9BGuC+wghMy5oMgdBdCK7xYKVQ5yuEQUj/pAOGvfr3nUxZnHZ5xMOFFb9dRoUXcGLJgMyEub+CRJRqk1p3HRjoug=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n h=to:subject:message-id:date:from:mime-version:dkim-signature;\n bh=+czjhYXQQbRosxdyEUD2PT+O2AHQOzxJ/XblKU7uYM0=;\n fh=oaSuqtdHlfrFL6BsfRwO9JDEf/VmsNPtxcnsvnORFSk=;\n b=SGgWPHdKF47J8B+bEHpPjppVRf4kWv50uTF+u26Kgc6BVMowumAqfNGHs/bEbBZ9Ld\n SRJm1fcogGt01jdDE31QzJL/4r7gMrMV0v9J+aAyomrXLGNQ2451i+f2rdNCajNsVD3O\n 6MfTVu/+hv2rrqisJEA03UPLsE7otKzg0JO+jJ3rU62nkCgMxEGlBlsDDfIISsM6lLAi\n uBUyIy9O4Twy0TfUpIjsahV7D4OnlBCVqbxcjKnZS/EyooMnI/cai9xIbZebS3AXsPKV\n ziZMKxcZroA/rMGi/D9ZLLDxIoQ5vZVI0XIb3wQCQDCF3Gd4mcxJrDCgGnl9Iyl7V4Gw\n wHwQ==; darn=gcc.gnu.org"],"ARC-Authentication-Results":["i=2; server2.sourceware.org","i=1; mx.google.com; arc=none"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775338696; x=1775943496; darn=gcc.gnu.org;\n h=to:subject:message-id:date:from:mime-version:from:to:cc:subject\n :date:message-id:reply-to;\n bh=+czjhYXQQbRosxdyEUD2PT+O2AHQOzxJ/XblKU7uYM0=;\n b=GeTEAgkX7/v+BmMi3t5iXMJfHtIDieq1Avwao9tCDk6Ug224WD7tT1et2ukS6JZDe8\n fWzlx6/LF90UW5+pYFwN/LExm2aHC1drEEbqyz71DiQj25xzpnuXgebVycOvMST5I+Me\n O3DsxnGm+Dh5UiNFbCbyniLASC/Srnlzz0Y0ZC7ZXWVT2IHXUSdowQi2fFRBjf7FlAf9\n p7QOr9vjWeci6K/x9OgL7/l3bzoBjRTiolfPAXPsWdRFj0NdE+XKKehpDYqhADNmR0Wy\n 6deKdrP3zOxbMaokBwci3cP70kAkJ16oyU/pa1r6wx55ufl4qdPDkDDwXdzk9aURAzzs\n G7DA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775338696; x=1775943496;\n h=to:subject:message-id:date:from:mime-version:x-gm-gg\n :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=+czjhYXQQbRosxdyEUD2PT+O2AHQOzxJ/XblKU7uYM0=;\n b=oHnTfTJgi5qFY6XzMYuRtHjtB/l8B54cS27jhHJ/8QqbXm49/WOLvXxskTIJFXEKSq\n WWCY104EemH8jV6lsR9z9uGr4ZgpgbzNeO9ZUwZqyclRRzFSMH7rov97Z9KIuB3GE3TM\n JQICpUTJHO3nx07WazlvLGhp7ADx5HkoMACQOqcH5LYaTzWHzPzZMafDTJbfihRztUf9\n 9CmVZz7g7jesgJSbOSwJkfVY2Hvqzxx/Klln5SQ4etTZ9S7Pt86BV7R9TyAK/2WP/KbB\n n4tOVhpL9dtFdKLdTVqcHB9TKpCz/+A0SSzBxj3jeX5tirEJK1KAxiDkpPL3WCWzpSoT\n 3viQ==","X-Forwarded-Encrypted":"i=1;\n AJvYcCUNTbEU4GD16jkxyii0dny5u14fK3D8Rv0Tef9XUvL++ZAmql7d9XY/m0gozMhOaP/ZxEiYzfhTG6Fkiw==@gcc.gnu.org","X-Gm-Message-State":"AOJu0YypPjSbteqx1r5Yx0N481+KBBViZ9xEYdXNpXCq34uUVunx55WL\n JKLmccb+WqjsS7hSBXA9ZXLzMMM6Ng3KhxYeVdUffUnT239qVNTqT4B2CucM7rogkNqjzPzEtSC\n rJWeNaEriQqm8klw4bTj/FK41sBdv8Oo=","X-Gm-Gg":"AeBDietD05Amahqa8RURwgBZV6LJYJeSQNkS+WGYHOU9yWb1/Ngvnz/bPp8HhmqFLfF\n XCRPlP207BqhFkwec7iiZ/xyH9eSlSIiIooXlmJYz8DO6s62aTVwrpBM7qVaEjmbll4ZsXYvMQd\n 27GDVxzWO9t4jyEJPWlSbdFJWpMnuDUyAHYCGLsNEaznnDVs7Djgni1VWp9Bj6xsh6d1SWmMyDc\n jk366s7dSG0v5hwKi1UVzo6hp7QKmMCUShRIGryqLaFUh2jtxPXdHFjZ0zo9E3tP/zdKVtDuin6\n wQ==","X-Received":"by 2002:a05:6102:6043:b0:604:f640:301e with SMTP id\n ada2fe7eead31-605a4e0219cmr2892213137.12.1775338696058; Sat, 04 Apr 2026\n 14:38:16 -0700 (PDT)","MIME-Version":"1.0","From":"Septicake <septicake056@gmail.com>","Date":"Sat, 4 Apr 2026 17:38:04 -0400","X-Gm-Features":"AQROBzCRmyxrKjkg4rmHj5cvLqqg0TJv0xcFt8ZOpPVJwbSBvKA8WQQebilCr4U","Message-ID":"\n <CANeSxVxSyDXvVgw6-F508k5YYvjsdZEoo+Ur=YPvEJ1OKs4=gw@mail.gmail.com>","Subject":"[PATCH] libstdc++: Allow for function parameters in\n annotations_of[_with_type] [P3795R2]","To":"\"libstdc++@gcc.gnu.org\" <libstdc++@gcc.gnu.org>, gcc-patches@gcc.gnu.org","Content-Type":"multipart/mixed; boundary=\"00000000000055c1a4064ea940c2\"","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":"This patch adds function parameters as an allowed reflection info that can\nbe passed to eval_annotations_of, and therefore the annotations_of and\nannotations_of_with_type metafunctions, following the update from P3795R2.\nThe error message when an invalid reflection info has been passed in has\nalso been updated to reflect this change.\n\nTested and bootstrapped on x86_64-pc-linux-gnu.\n\ngcc/\n\n* cp/reflect.cc (eval_annotations_of): Allow function parameters and update\nerror message\naccordingly\n\ngcc/testsuite/\n\n* g++.dg/reflect/annotations18.C: New test\n* g++.dg/reflect/annotations19.C: Likewise\n* g++.dg/reflect/annotations20.C: Likewise","diff":"From 8894d4bbca547afe170a3faba03fbfdb2da23bed Mon Sep 17 00:00:00 2001\nFrom: Septicake <septicake056@gmail.com>\nDate: Sat, 4 Apr 2026 15:46:40 -0400\nSubject: [PATCH] libstdc++: Allow for function parameters in\n annotations_of[_with_type] [P3795R2]\n\nSigned-off-by: Septicake <septicake056@gmail.com>\n---\n gcc/cp/reflect.cc                            |  8 +++++---\n gcc/testsuite/g++.dg/reflect/annotations18.C | 14 ++++++++++++++\n gcc/testsuite/g++.dg/reflect/annotations19.C | 20 ++++++++++++++++++++\n gcc/testsuite/g++.dg/reflect/annotations20.C | 19 +++++++++++++++++++\n 4 files changed, 58 insertions(+), 3 deletions(-)\n create mode 100644 gcc/testsuite/g++.dg/reflect/annotations18.C\n create mode 100644 gcc/testsuite/g++.dg/reflect/annotations19.C\n create mode 100644 gcc/testsuite/g++.dg/reflect/annotations20.C\n\ndiff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc\nindex df7f0b54b5b..f9dd331dd82 100644\n--- a/gcc/cp/reflect.cc\n+++ b/gcc/cp/reflect.cc\n@@ -3818,15 +3818,17 @@ eval_annotations_of (location_t loc, const constexpr_ctx *ctx, tree r,\n \t|| eval_is_type_alias (r) == boolean_true_node\n \t|| eval_is_variable (r, kind) == boolean_true_node\n \t|| eval_is_function (r) == boolean_true_node\n+\t|| eval_is_function_parameter (r, kind) == boolean_true_node\n \t|| eval_is_namespace (r) == boolean_true_node\n \t|| eval_is_enumerator (r) == boolean_true_node\n \t|| eval_is_base (r, kind) == boolean_true_node\n \t|| eval_is_nonstatic_data_member (r) == boolean_true_node))\n     return throw_exception (loc, ctx,\n \t\t\t    \"reflection does not represent a type,\"\n-\t\t\t    \" type alias, variable, function, namespace,\"\n-\t\t\t    \" enumerator, direct base class relationship,\"\n-\t\t\t    \" or non-static data member\",\n+\t\t\t    \" type alias, variable, function, function\"\n+\t\t\t    \" parameter, namespace, enumerator, direct\"\n+\t\t\t    \" base class relationship, or non-static\"\n+\t\t\t    \" data member.\",\n \t\t\t    fun, non_constant_p, jump_target);\n \n   if (type)\ndiff --git a/gcc/testsuite/g++.dg/reflect/annotations18.C b/gcc/testsuite/g++.dg/reflect/annotations18.C\nnew file mode 100644\nindex 00000000000..8400ee30ac5\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/annotations18.C\n@@ -0,0 +1,14 @@\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+// Test annotations_of on function parameter reflections\n+\n+#include <meta>\n+\n+using namespace std::meta;\n+\n+void foo([[=2]] int);\n+\n+void foo([[=1]] int) {}\n+\n+static_assert (define_static_array(annotations_of(parameters_of(^^foo)[0])).size() == 2);\n+static_assert ([: constant_of(annotations_of(parameters_of(^^foo)[0])[0]) :] == 2);\ndiff --git a/gcc/testsuite/g++.dg/reflect/annotations19.C b/gcc/testsuite/g++.dg/reflect/annotations19.C\nnew file mode 100644\nindex 00000000000..2d9b9cc3a16\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/annotations19.C\n@@ -0,0 +1,20 @@\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+// Test annotations_of_with_type works as expected\n+\n+#include <meta>\n+#include <ranges>\n+#include <vector>\n+\n+using namespace std::meta;\n+\n+void foo([[=1, =2.0f, =2.3f]] int) {\n+    constexpr auto a_p = define_static_array(annotations_of_with_type(parameters_of(^^foo)[0], ^^float));\n+\n+    static_assert(a_p.size() == 2);\n+    static_assert((annotations_of_with_type(parameters_of(^^foo)[0], ^^float)\n+                  | std::views::transform(constant_of)\n+                  | std::ranges::to<std::vector>())\n+            == std::vector { reflect_constant(2.0f),\n+                             reflect_constant(2.3f) });\n+}\ndiff --git a/gcc/testsuite/g++.dg/reflect/annotations20.C b/gcc/testsuite/g++.dg/reflect/annotations20.C\nnew file mode 100644\nindex 00000000000..80db4a1bbbf\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/annotations20.C\n@@ -0,0 +1,19 @@\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+// Test that annotations match between\n+// variable and parameter reflections\n+\n+#include <meta>\n+\n+using namespace std::meta;\n+\n+void foo([[=2]] int);\n+\n+void foo([[=1]] int i) {\n+    constexpr info p_r = parameters_of(^^foo)[0];\n+    constexpr info i_r = ^^i;\n+\n+    static_assert(define_static_array(annotations_of(p_r)).size() == 2);\n+    static_assert(define_static_array(annotations_of(i_r)).size() == 2);\n+    static_assert(annotations_of(p_r) == annotations_of(i_r));\n+}\n-- \n2.43.0\n\n","prefixes":[]}