Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217813/?format=api
{ "id": 2217813, "url": "http://patchwork.ozlabs.org/api/patches/2217813/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/acqexNg5nIsAdXyG@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": "<acqexNg5nIsAdXyG@tucnak>", "list_archive_url": null, "date": "2026-03-30T16:03:16", "name": "c++: Fix up access_context::current and current_namespace", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "7d385ed233d70b0ac4852122d616b088844149d7", "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/acqexNg5nIsAdXyG@tucnak/mbox/", "series": [ { "id": 498063, "url": "http://patchwork.ozlabs.org/api/series/498063/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=498063", "date": "2026-03-30T16:03:16", "name": "c++: Fix up access_context::current and current_namespace", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498063/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217813/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217813/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=hzZfgzye;\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=hzZfgzye", "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 [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 4fkwzN53f8z1yG8\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 03:03:59 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 49B734BB58E6\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 16:03:52 +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 941604BA23EC\n for <gcc-patches@gcc.gnu.org>; Mon, 30 Mar 2026 16:03:22 +0000 (GMT)", "from mx-prod-mc-06.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-117-nVchwti7NAywwmb-pfOA4Q-1; Mon,\n 30 Mar 2026 12:03:20 -0400", "from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id C9C031800561\n for <gcc-patches@gcc.gnu.org>; Mon, 30 Mar 2026 16:03:19 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.44.32.9])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 16CEE19560AB; Mon, 30 Mar 2026 16:03:18 +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 62UG3GES620900\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Mon, 30 Mar 2026 18:03:16 +0200", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 62UG3GZg620899;\n Mon, 30 Mar 2026 18:03:16 +0200" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 49B734BB58E6", "OpenDKIM Filter v2.11.0 sourceware.org 941604BA23EC" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 941604BA23EC", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 941604BA23EC", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774886602; cv=none;\n b=rI+qYEQrlEYhyKMIP5a66BM5VS6NMaAc34fVGOSxLp/DC3rsgSNIh06plvwRQPQdoedeF3heX1BNpDNxWT98euTQinwybtyn4N9jA1HP2f+A1Tx2Iki5E3tlWDgFmjhxoTLWtmA07sYy8MLLSephWmFIAeC/+KZbstK2wJO8oPQ=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774886602; c=relaxed/simple;\n bh=rZ5kajiaTVbJSDb2zjid0B32ZwOVPzds2Ie7sTeA+MA=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=kSy8D8T6Yg/pP672WveS8OiBjMmRRR1TwnrUB1GaKm5wJPTXrhLTrYLwxWHn1Dvdxe4fnBhJbStKvll5XHAtyyQhc/Fw4MjmjTD1UI1S6WsX1J+LHNT6oG6gIiLL/HcaRZV9G2jrzbye8N6pw+I6WhuhOuxGaNbagLX+E56yTbU=", "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=1774886602;\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=B2OJMSrPzszfY+SIsjdHyKHS21GWmlXIOXwTmDOOm38=;\n b=hzZfgzyetjImOa808ZnW5BRqDKL/HSz+eL+eEktAKCFJ3NtU3ZuXoeECXdHo4oqbmLQBC0\n TIRPPEkzsyZD5Q2NOSoBUQus87mR+9XHAx/yfOPKGQQ6Pv+2M8BkmG3ELzKORiE5UeQOAq\n QHXCf5jl5zfYkwtOqpI2tr9EEdHnTJU=", "X-MC-Unique": "nVchwti7NAywwmb-pfOA4Q-1", "X-Mimecast-MFC-AGG-ID": "nVchwti7NAywwmb-pfOA4Q_1774886600", "Date": "Mon, 30 Mar 2026 18:03:16 +0200", "From": "Jakub Jelinek <jakub@redhat.com>", "To": "Jason Merrill <jason@redhat.com>, Marek Polacek <polacek@redhat.com>,\n Tomasz Kaminski <tkaminsk@redhat.com>", "Cc": "Jonathan Wakely <jwakely@redhat.com>, gcc-patches@gcc.gnu.org", "Subject": "[PATCH] c++: Fix up access_context::current and current_namespace", "Message-ID": "<acqexNg5nIsAdXyG@tucnak>", "References": "<acay_1BCmIb6JYbg@tucnak>\n <CAKvuMXB8ziOkuZgZsuGjKNxuA0b4GF-aepFK9QWds3uB==+BaA@mail.gmail.com>\n <acpV3PrRAQDB8IAj@tucnak>\n <CAKvuMXCkOQOaV5HABCZVaDKai02ZXUjMJp3f8cbaNF-CV1HP2g@mail.gmail.com>", "MIME-Version": "1.0", "In-Reply-To": "\n <CAKvuMXCkOQOaV5HABCZVaDKai02ZXUjMJp3f8cbaNF-CV1HP2g@mail.gmail.com>", "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.12", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "5_KXnzuYAE9NnW54salycWcfkWJrKyj8Ycb_EsZLGwY_1774886600", "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 Mon, Mar 30, 2026 at 01:15:07PM +0200, Tomasz Kaminski wrote:\n> > auto\n> > Q::baz () -> typename [: current_namespace () == ^^Q ? ^^int : ^^:: :]\n> > {\n> > return 0;\n> > }\n> > part also fails, there I don't know what's right but possibly it should\n> > be in Q; in that case it would be a pre-existing bug already for\n> > std::meta::access_context::current () too.\n> >\n> My reading of the standard may be wrong here.\n\nI think you're right, but because it is a preexisting bug on\naccess_context, sending this as a separate patch rather than\nupdating the current_* patch.\n\nTested on x86_64-linux, ok for trunk?\n\n2026-03-30 Jakub Jelinek <jakub@redhat.com>\n\n\t* reflect.cc (current_scope): Use decl_namespace_list->last ()\n\tin preference to current_namespace.\n\n\t* g++.dg/reflect/access_context1.C: Add new tests.\n\t* g++.dg/reflect/current_function1.C: Likewise.\n\t* g++.dg/reflect/current_class1.C: Likewise.\n\t* g++.dg/reflect/current_class2.C: Likewise.\n\t* g++.dg/reflect/current_namespace1.C: Likewise.\n\n\n\n\tJakub", "diff": "--- gcc/cp/reflect.cc.jj\t2026-03-30 15:43:40.046055479 +0200\n+++ gcc/cp/reflect.cc\t2026-03-30 16:41:50.496455140 +0200\n@@ -6266,6 +6266,9 @@ current_scope (location_t loc, const con\n \t}\n if (current_class_type)\n \tscope = current_class_type;\n+ /* If we have been pushed into a different namespace, use it. */\n+ else if (!vec_safe_is_empty (decl_namespace_list))\n+\tscope = decl_namespace_list->last ();\n else if (current_namespace)\n \tscope = current_namespace;\n else\n--- gcc/testsuite/g++.dg/reflect/access_context1.C.jj\t2026-03-27 10:17:16.113298446 +0100\n+++ gcc/testsuite/g++.dg/reflect/access_context1.C\t2026-03-30 16:45:48.856419423 +0200\n@@ -146,6 +146,8 @@ namespace O\n {\n return a;\n }\n+ int bar ();\n+ int baz ();\n }\n \n consteval bool\n@@ -156,6 +158,18 @@ can_do_via (info r)\n return true;\n }\n \n+typename [: access_context::current ().scope () == ^^:: ? ^^int : ^^:: :]\n+O::bar ()\n+{\n+ return 0;\n+}\n+\n+auto\n+O::baz () -> typename [: access_context::current ().scope () == ^^O ? ^^int : ^^:: :]\n+{\n+ return 0;\n+}\n+\n struct W;\n \n static_assert (can_do_via (^^S));\n--- gcc/testsuite/g++.dg/reflect/current_function1.C.jj\t2026-03-30 15:43:40.046585352 +0200\n+++ gcc/testsuite/g++.dg/reflect/current_function1.C\t2026-03-30 16:18:04.186582636 +0200\n@@ -38,6 +38,11 @@ struct V : U\n info v = current_function ();\n };\n \n+struct W : T\n+{\n+ info w = current_function ();\n+};\n+\n void\n bar ()\n {\n@@ -45,6 +50,7 @@ bar ()\n static_assert (foo (^^foo) == ^^foo);\n static_assert (foo () == ^^bar);\n static_assert (T {}.t == ^^bar);\n+ static_assert (is_constructor (T ().t) && parent_of (T ().t) == ^^T);\n consteval {\n static_assert (current_function () == ^^bar);\n consteval {\n@@ -74,3 +80,14 @@ baz ()\n }\n \n static_assert (baz ());\n+\n+consteval void\n+fred ()\n+{\n+ constexpr W w;\n+ static_assert (is_constructor (w.t) && parent_of (w.t) == ^^T);\n+ static_assert (is_constructor (w.w) && parent_of (w.w) == ^^W);\n+ constexpr W wb {};\n+ static_assert (wb.t == ^^fred);\n+ static_assert (wb.w == ^^fred);\n+}\n--- gcc/testsuite/g++.dg/reflect/current_class1.C.jj\t2026-03-30 15:43:40.046798328 +0200\n+++ gcc/testsuite/g++.dg/reflect/current_class1.C\t2026-03-30 16:22:13.327347979 +0200\n@@ -68,3 +68,16 @@ bar ()\n static_assert (parent_of (current_class ()) == ^^bar);\n };\n }\n+\n+struct X {\n+ struct Y {\n+ int foo ();\n+ };\n+};\n+\n+auto\n+X::Y::foo ()\n+-> typename [: current_class () == ^^Y ? ^^int : ^^:: :]\n+{\n+ return 0;\n+}\n--- gcc/testsuite/g++.dg/reflect/current_class2.C.jj\t2026-03-30 15:43:40.046889261 +0200\n+++ gcc/testsuite/g++.dg/reflect/current_class2.C\t2026-03-30 16:25:32.717970634 +0200\n@@ -71,3 +71,15 @@ namespace O\n return a;\t\t\t\t\t\t// { dg-error \"invalid initialization of reference of type\" }\n }\n }\n+\n+struct X {\n+ struct Y {\n+ int foo ();\n+ };\n+};\n+\n+typename [: current_class () == ^^X ? ^^int : ^^:: :]\t// { dg-error \"uncaught exception of type 'std::meta::exception'; 'what\\\\\\(\\\\\\)': 'current scope does not represent a class nor a member function'\" }\n+X::Y::foo ()\t\t\t\t\t\t// { dg-error \"expected unqualified-id before 'typename'\" \"\" { target *-*-* } .-1 }\n+{\n+ return 0;\n+}\n--- gcc/testsuite/g++.dg/reflect/current_namespace1.C.jj\t2026-03-30 15:43:40.046986219 +0200\n+++ gcc/testsuite/g++.dg/reflect/current_namespace1.C\t2026-03-30 16:12:39.851641760 +0200\n@@ -90,4 +90,19 @@ namespace Q\n {\n return a;\n }\n+\n+ int bar ();\n+ int baz ();\n+}\n+\n+typename [: current_namespace () == ^^:: ? ^^int : ^^:: :]\n+Q::bar ()\n+{\n+ return 0;\n+}\n+\n+auto\n+Q::baz () -> typename [: current_namespace () == ^^Q ? ^^int : ^^:: :]\n+{\n+ return 0;\n }\n", "prefixes": [] }