Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218121/?format=api
{ "id": 2218121, "url": "http://patchwork.ozlabs.org/api/patches/2218121/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/acvGF_EmFLvxEAOb@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": "<acvGF_EmFLvxEAOb@tucnak>", "list_archive_url": null, "date": "2026-03-31T13:03:19", "name": "c++: Implement CWG3124 - Disallow annotations on block-scope externs and non-unique friend declarations", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "3324bb9606f043b3241890946d08cce3785609b9", "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/acvGF_EmFLvxEAOb@tucnak/mbox/", "series": [ { "id": 498193, "url": "http://patchwork.ozlabs.org/api/series/498193/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=498193", "date": "2026-03-31T13:03:19", "name": "c++: Implement CWG3124 - Disallow annotations on block-scope externs and non-unique friend declarations", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498193/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218121/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2218121/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=GUKwIuNj;\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=GUKwIuNj", "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 4flSxB3gXqz1y1q\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 01 Apr 2026 00:03:58 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 755134BB58F5\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 13:03:56 +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 6F6B44BA540B\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 13:03:28 +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-325-bYWY0mnjMqCQjCCd500BBQ-1; Tue,\n 31 Mar 2026 09:03:25 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id E0035180060D\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 13:03:22 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.44.32.9])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 3F7821800107; Tue, 31 Mar 2026 13:03:22 +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 62VD3JAi4138350\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Tue, 31 Mar 2026 15:03:19 +0200", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 62VD3JuZ4138349;\n Tue, 31 Mar 2026 15:03:19 +0200" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 755134BB58F5", "OpenDKIM Filter v2.11.0 sourceware.org 6F6B44BA540B" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 6F6B44BA540B", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 6F6B44BA540B", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774962208; cv=none;\n b=htylMwzrIQ6GPIXPE2p+h1HElYTth5z4dT5LAuUyWcUtoNA3/y+3IJjYXUD4AM0pKJspPMBC/dPSE3QciGd9CWLRRJbnhKP9owetcTpWEHGWP2ysK5EOKV2ICbq7H1g6lpT2ieAM43uhYKdE0PXZVbHmO+FHKSushSTtzQEE0ps=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774962208; c=relaxed/simple;\n bh=EajzAcV5ap3jo8SonFHkWmV4ZjcDeE58eD8zKryKBTI=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=E7dCKqM4B2lOn9HtrIebeFq8v5VmmzVZB2KHaNtqQj0wf87bzBQTZ0UOXWAKEfvPhkPhvglbLtT9pFoZsB5Xutk/6wsB9Bq1RSZAL4niXXh6gRp3sj1bZcO7qEk8pICreFnE3qvCyBO6yyPhoWkXRusUBsvWmgsVTxQpIAluoqI=", "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=1774962208;\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=OF9zc0FjAp0taDuLsIDFW4yWq+hE1hiHjuDiICBWxGI=;\n b=GUKwIuNjYoFF1wyI4T8PVrQClp186ZSr/+gfnzr7H5J3rFe71+A8fit2u5emB2HomhZTdZ\n VR9J2BD8k7NSm4dK7Goo3cobPQyP34QcsJNfvjT3dSvppIPE6AHLUmGsAp0J2EdO8PUjtF\n EQrCiUKxmy7NQJexI+Xi5e/Wv9V/U/U=", "X-MC-Unique": "bYWY0mnjMqCQjCCd500BBQ-1", "X-Mimecast-MFC-AGG-ID": "bYWY0mnjMqCQjCCd500BBQ_1774962203", "Date": "Tue, 31 Mar 2026 15:03:19 +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++: Implement CWG3124 - Disallow annotations on block-scope\n externs and non-unique friend declarations", "Message-ID": "<acvGF_EmFLvxEAOb@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": "Z-nbUBywwBJZkObyxSPqkgjNcce3r4ZmSTz6O17XnGY_1774962203", "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\nThis issue says it is invalid to declare annotations on local externs or\nnon-defining friends and their arguments (if any).\n\nTested on x86_64-linux, ok for trunk?\n\n2026-03-31 Jakub Jelinek <jakub@redhat.com>\n\n\t* name-lookup.cc (push_local_extern_decl_alias): Diagnose annotations\n\ton local externs and their arguments.\n\t* decl.cc (grokdeclarator): Diagnose annotations on non-defining\n\tfriends and their arguments.\n\n\t* g++.dg/reflect/annotations17.C: New test.\n\n\n\tJakub", "diff": "--- gcc/cp/name-lookup.cc.jj\t2026-03-27 10:17:14.025332518 +0100\n+++ gcc/cp/name-lookup.cc\t2026-03-31 14:14:32.074001334 +0200\n@@ -3690,6 +3690,22 @@ set_decl_context_in_fn (tree ctx, tree d\n void\n push_local_extern_decl_alias (tree decl)\n {\n+ if (flag_reflection)\n+ {\n+ if (lookup_attribute (\"internal \", \"annotation \",\n+\t\t\t DECL_ATTRIBUTES (decl)))\n+\terror_at (DECL_SOURCE_LOCATION (decl),\n+\t\t \"annotation applied to block scope extern %qD\",\n+\t\t decl);\n+ if (TREE_CODE (decl) == FUNCTION_DECL)\n+\tfor (tree arg = DECL_ARGUMENTS (decl); arg; arg = DECL_CHAIN (arg))\n+\t if (lookup_attribute (\"internal \", \"annotation \",\n+\t\t\t\tDECL_ATTRIBUTES (arg)))\n+\t error_at (DECL_SOURCE_LOCATION (arg),\n+\t\t \"annotation applied to parameter %qD of block scope \"\n+\t\t \"extern\", arg);\n+ }\n+\n if (dependent_type_p (TREE_TYPE (decl))\n || (processing_template_decl\n \t && VAR_P (decl)\n--- gcc/cp/decl.cc.jj\t2026-03-27 18:34:12.491773781 +0100\n+++ gcc/cp/decl.cc\t2026-03-31 14:41:57.698215424 +0200\n@@ -16618,6 +16618,25 @@ grokdeclarator (const cp_declarator *dec\n \n \tif (friendp)\n \t {\n+\t if (flag_reflection && !funcdef_flag && decl)\n+\t {\n+\t\tif (attrlist\n+\t\t && lookup_attribute (\"internal \", \"annotation \",\n+\t\t\t\t\t *attrlist))\n+\t\t {\n+\t\t *attrlist = remove_attribute (\"internal \", \"annotation \",\n+\t\t\t\t\t\t *attrlist);\n+\t\t error_at (id_loc, \"annotation applied to non-defining \"\n+\t\t\t\t \"friend declaration %qD\", decl);\n+\t\t }\n+\t\tfor (tree arg = DECL_ARGUMENTS (decl);\n+\t\t arg; arg = DECL_CHAIN (arg))\n+\t\t if (lookup_attribute (\"internal \", \"annotation \",\n+\t\t\t\t\tDECL_ATTRIBUTES (arg)))\n+\t\t error_at (DECL_SOURCE_LOCATION (arg),\n+\t\t\t \"annotation applied to parameter %qD of \"\n+\t\t\t \"non-defining friend declaration\", arg);\n+\t }\n \t /* Packages tend to use GNU attributes on friends, so we only\n \t warn for standard attributes. */\n \t if (attrlist\n--- gcc/testsuite/g++.dg/reflect/annotations17.C.jj\t2026-03-31 13:36:13.365771983 +0200\n+++ gcc/testsuite/g++.dg/reflect/annotations17.C\t2026-03-31 14:48:29.229602662 +0200\n@@ -0,0 +1,53 @@\n+// CWG3124 - Disallow annotations on block-scope externs and non-unique friend declarations\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+void\n+foo ()\n+{\n+ [[=1]] extern int a;\t\t\t// { dg-error \"annotation applied to block scope extern 'a'\" }\n+ extern int b [[=2]];\t\t\t// { dg-error \"annotation applied to block scope extern 'b'\" }\n+ [[=3]] extern int bar (int);\t\t// { dg-error \"annotation applied to block scope extern 'int bar\\\\\\(int\\\\\\)'\" }\n+ extern int baz [[=4]] (int);\t\t// { dg-error \"annotation applied to block scope extern 'int baz\\\\\\(int\\\\\\)'\" }\n+ extern int qux (int a[[=5]]);\t\t// { dg-error \"annotation applied to parameter 'a' of block scope extern\" }\n+}\n+\n+class S\n+{\n+ int s;\n+ S ();\n+ [[=6]] friend void corge ();\t\t// { dg-error \"annotation applied to non-defining friend declaration 'void corge\\\\\\(\\\\\\)'\" }\n+ friend void garply ([[=7]] int a);\t// { dg-error \"annotation applied to parameter 'a' of non-defining friend declaration\" }\n+ [[=8]] friend void fred () {}\n+ friend void xyzzy (int a[[=9]]) {}\n+ template <typename T>\n+ [[=10]] friend void quux ();\t\t// { dg-error \"annotation applied to non-defining friend declaration 'void quux\\\\\\(\\\\\\)'\" }\n+ template <typename T>\n+ friend void grault ([[=11]] int a);\t// { dg-error \"annotation applied to parameter 'a' of non-defining friend declaration\" }\n+ template <typename T>\n+ [[=12]] friend void waldo () {}\n+ template <typename T>\n+ friend void thud (int a[[=13]]) {}\n+};\n+\n+template <typename T>\n+class U\n+{\n+ int u;\n+ [[=14]] friend void corge (long);\t// { dg-error \"annotation applied to non-defining friend declaration 'void corge\\\\\\(long int\\\\\\)'\" }\n+ friend void garply (long, [[=16]] int a);\t// { dg-error \"annotation applied to parameter 'a' of non-defining friend declaration\" }\n+ [[=16]] friend void fred (long) {}\n+ friend void xyzzy (long, int a[[=17]]) {}\n+ template <typename V>\n+ [[=18]] friend void quux (long);\t// { dg-error \"annotation applied to non-defining friend declaration 'void quux\\\\\\(long int\\\\\\)'\" }\n+ template <typename V>\n+ friend void grault (long, [[=19]] int a);\t// { dg-error \"annotation applied to parameter 'a' of non-defining friend declaration\" }\n+ template <typename V>\n+ [[=20]] friend void waldo (long) {}\n+ template <typename V>\n+ friend void thud (long, int a[[=21]]) {}\n+public:\n+ U () : u (42) {}\n+};\n+\n+U <int> u;\n", "prefixes": [] }