{"id":2224109,"url":"http://patchwork.ozlabs.org/api/patches/2224109/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/aeFFooo_IfeHlQCw@redhat.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":"<aeFFooo_IfeHlQCw@redhat.com>","list_archive_url":null,"date":"2026-04-16T20:25:06","name":"[v2] c++/reflection: splicing null reflection","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"812676607cca705301a042f592fb3518a70321a4","submitter":{"id":14370,"url":"http://patchwork.ozlabs.org/api/people/14370/?format=json","name":"Marek Polacek","email":"polacek@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/aeFFooo_IfeHlQCw@redhat.com/mbox/","series":[{"id":500202,"url":"http://patchwork.ozlabs.org/api/series/500202/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500202","date":"2026-04-16T20:25:06","name":"[v2] c++/reflection: splicing null reflection","version":2,"mbox":"http://patchwork.ozlabs.org/series/500202/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224109/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224109/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=hBSGX7jw;\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=hBSGX7jw","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 4fxTzl3k0Bz1yG9\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 06:25:54 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id E874B4BA903C\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 20:25:50 +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 EEAFC4C515D9\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 20:25:11 +0000 (GMT)","from mail-qv1-f69.google.com (mail-qv1-f69.google.com\n [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-173-o6vGWUViP1mX4altSjLXrA-1; Thu, 16 Apr 2026 16:25:10 -0400","by mail-qv1-f69.google.com with SMTP id\n 6a1803df08f44-8abd6e281c0so233555076d6.1\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 13:25:10 -0700 (PDT)","from redhat.com ([2603:7000:9500:10::1db4])\n by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8ae6c9593d1sm43836066d6.13.2026.04.16.13.25.07\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 16 Apr 2026 13:25:07 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org E874B4BA903C","OpenDKIM Filter v2.11.0 sourceware.org EEAFC4C515D9"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org EEAFC4C515D9","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org EEAFC4C515D9","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776371112; cv=none;\n b=ebZncyMmqr+447g3kMlH60cQe3WZMWed/564XUS2QgQS0EdXu09FvMFUB36xgHzZXmN/7E4PNPv5Fn8iu1mGw0bQYoroQEyfcY6Ib9QHZld6s7f2XhRM7tMcjGfgaMgfuRsbI8aXlp29FPn0dtwjRWY+VETwYi+VVeHrpk4prbs=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776371112; c=relaxed/simple;\n bh=u0deqqTayRR4pxzr6rsIoznIX7wElMt6NOfkKxZ+pmg=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=OkXPudg2Ch/nalJkNsAP16qFt6cW6dYJcEmOumsglKXpkWzX2yAiMvFTJfL9bq0hQDWQnAKx4lED7dY+H1hXRHI1Dq/8d8xF2KlQCTx0uK0fhp7OQCxPWpR3gRQzwTQOxrBgtO/sUf55Utg/LpO0RqUeHNO4q0Zr0HcQmWS6wCA=","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=1776371111;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n in-reply-to:in-reply-to:references:references;\n bh=Cyt4nvPpplneBGjdZDlzI8dpoH5mJ5Fnv22/pKi8yps=;\n b=hBSGX7jwylt55+881JbQPaw8BGoDR+iXfXsLGf1bMT6+71WsSCNcEaFT0VGW25gxiBergQ\n 4+AFQ80bW1Lsz2emJ3c77Yi3LVq8Rvy/3z339CH7p5aDNidpWNWtr3mdLk919mq64ePCwL\n DgvnhYCoUXJKJfD1a9UqncKp1f9w93s=","X-MC-Unique":"o6vGWUViP1mX4altSjLXrA-1","X-Mimecast-MFC-AGG-ID":"o6vGWUViP1mX4altSjLXrA_1776371109","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776371109; x=1776975909;\n h=user-agent:in-reply-to:content-disposition:mime-version:references\n :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=Cyt4nvPpplneBGjdZDlzI8dpoH5mJ5Fnv22/pKi8yps=;\n b=jSodn0KEsMkk39PFAAImRjPf9qe2sroTkd+e9XuVFdD2aWMu8uaPUc+DPoBjx0Mqtz\n RRkX+TXo95g6q4QZHHiomZeaLHzxMhMtTZvvfAZBJ/5fgzGDB19hLjjJ9KmrbKHaGgxU\n GTztA2QKhQZVREyflrZVeYYHcVImGVeXME6kMETyJbjXVDbe4WuDW04GB2gwMEOlnTaG\n I/Z6ZjHMK1EGfttbOSSCMRxAAP05K2i58QfIUNfQhJJU5HR+igmj5bUVsTK5/QBn4Q//\n QuYeFiOuvGJETUHqfz0ml11YbZuyMhS8OxpBTag/jZG0m+IpePMDRakO9+QY9mD5FW1e\n f0LA==","X-Gm-Message-State":"AOJu0YxEVLeGRbZGih99j3hnOrjv6WiWvB3iY4BGYMzoX0WF+CRvNlr1\n GKWQByCx3vVhNbPMIa4Zdpl9L0ofs6XHDaMetQG8YCYPnYdzEw4ofVf0m75x1DVOoUb5n7uVI2y\n lL4k14EOqydG/5IeGWAKyYlMlALzVXeDfMaL9PIV++lRu8SFbcObykW7Gc5c=","X-Gm-Gg":"AeBDievTrykKEZreDNWD5xQsQfG+5E2QPdfONQOSNcgYZte3W7jhXvZopnynKtqVujF\n 11GX7zOoq4HS3RlzrKxJ/2tgFuEBNq1mZlfeLPoLl+3E3W763YOKzjuRke9o44cwcI5k+JzI2Yo\n 4OwXXNdc/7wDJzFA51xtGMgupvvkLqXFVIU4j6jXu9ZOJURC6e+vy0CdciTPSWPmZcWYsPpESfZ\n J63Aw6E3e+XyVaf0kYf2Xfoy3rf7N1Bj1u5NfE8ev8ULz13NOTuOzPf1T4A57/OwF80OlZrLKAW\n NAy5G8VlpZp6+cFDIRZJuhQTC7l2BpG82ks8sTMKjSErXYYbVsmhMuYtIqP2pkdEGUzRlqqtiWN\n 5DM4SO+kYhAdv","X-Received":["by 2002:a05:6214:29e9:b0:89c:6bbd:76d8 with SMTP id\n 6a1803df08f44-8b0280b2f12mr350296d6.19.1776371109170;\n Thu, 16 Apr 2026 13:25:09 -0700 (PDT)","by 2002:a05:6214:29e9:b0:89c:6bbd:76d8 with SMTP id\n 6a1803df08f44-8b0280b2f12mr349546d6.19.1776371108599;\n Thu, 16 Apr 2026 13:25:08 -0700 (PDT)"],"Date":"Thu, 16 Apr 2026 16:25:06 -0400","From":"Marek Polacek <polacek@redhat.com>","To":"Jason Merrill <jason@redhat.com>","Cc":"GCC Patches <gcc-patches@gcc.gnu.org>","Subject":"[PATCH v2] c++/reflection: splicing null reflection","Message-ID":"<aeFFooo_IfeHlQCw@redhat.com>","References":"<20260415235200.1576761-1-polacek@redhat.com>\n <05317d8e-be32-4c67-8d50-becc3864e65e@redhat.com>\n <aeECjy5O6sXf2YA5@redhat.com>\n <dac6ba8a-3425-4993-8634-5a7aebe376b6@redhat.com>","MIME-Version":"1.0","In-Reply-To":"<dac6ba8a-3425-4993-8634-5a7aebe376b6@redhat.com>","User-Agent":"Mutt/2.3.1 (2026-03-20)","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"x0wwk0WdiY6nqE9u_QYt6gSZmOwXzVutIs5UkzUWT1Q_1776371109","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":"On Thu, Apr 16, 2026 at 01:29:29PM -0400, Jason Merrill wrote:\n> On 4/16/26 11:38 AM, Marek Polacek wrote:\n> > On Thu, Apr 16, 2026 at 09:40:47AM -0400, Jason Merrill wrote:\n> > > On 4/15/26 7:52 PM, Marek Polacek wrote:\n> > > > Tested reflect/* on x86_64-pc-linux-gnu, ok for trunk?\n> > > > \n> > > > -- >8 --\n> > > > Here we are printing:\n> > > > \n> > > >     note: but ''lang_type' not supported by dump_expr<expression error>' is a type\n> > > > \n> > > > because we represent a null reflection with unknown_type_node.  Let's\n> > > > not print anything in that case; unknown_type_node can also be\n> > > > <unresolved overloaded function type>.\n> > > \n> > > Can we diagnose sooner trying to splice a null reflection?  That should be\n> > > ill-formed regardless of whether we expect it to be a type or expression or\n> > > whatever.\n> > \n> > Sounds good, thanks.\n> > \n> > Tested reflect/* on x86_64-pc-linux-gnu, ok for trunk?\n> > \n> > -- >8 --\n> > Here we are printing:\n> > \n> >    note: but ''lang_type' not supported by dump_expr<expression error>' is a type\n> > \n> > because we represent a null reflection with unknown_type_node.  Let's\n> > detect splicing a null reflection.\n> > \n> > gcc/cp/ChangeLog:\n> > \n> > \t* reflect.cc (check_splice_expr): Detect a null reflection.\n> > \n> > gcc/testsuite/ChangeLog:\n> > \n> > \t* g++.dg/reflect/null6.C: New test.\n> > ---\n> >   gcc/cp/reflect.cc                    | 7 +++++++\n> >   gcc/testsuite/g++.dg/reflect/null6.C | 6 ++++++\n> >   2 files changed, 13 insertions(+)\n> >   create mode 100644 gcc/testsuite/g++.dg/reflect/null6.C\n> > \n> > diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc\n> > index 2b7e7033953..ea7616a62bc 100644\n> > --- a/gcc/cp/reflect.cc\n> > +++ b/gcc/cp/reflect.cc\n> > @@ -8929,6 +8929,13 @@ check_splice_expr (location_t loc, location_t start_loc, tree t,\n> >   \t\t   bool address_p, bool member_access_p, bool template_p,\n> >   \t\t   bool targs_p, bool complain_p)\n> >   {\n> > +  if (t == unknown_type_node)\n> > +    {\n> > +      if (complain_p)\n> > +\terror_at (loc, \"cannot splice a null reflection\");\n> > +      return false;\n> > +    }\n> > +\n> >     /* We may not have gotten an expression.  */\n> >     if (TREE_CODE (t) == TYPE_DECL\n> >         || TREE_CODE (t) == NAMESPACE_DECL\n> > diff --git a/gcc/testsuite/g++.dg/reflect/null6.C b/gcc/testsuite/g++.dg/reflect/null6.C\n> > new file mode 100644\n> > index 00000000000..bfa2b6ba241\n> > --- /dev/null\n> > +++ b/gcc/testsuite/g++.dg/reflect/null6.C\n> > @@ -0,0 +1,6 @@\n> > +// { dg-do compile { target c++26 } }\n> > +// { dg-additional-options \"-freflection\" }\n> > +\n> > +using info = decltype(^^::);\n> > +constexpr auto null = info{};\n> > +constexpr auto q = [:null:];  // { dg-error \"cannot splice a null reflection\" }\n> \n> Please also test null in a splice-type-specifier, with and without template\n> arguments.\n\nDone.  And actually let's check for a null reflection in splice.  This\nis on top of Jakub's PR123783 patch.\n\nTested reflect/* on x86_64-pc-linux-gnu, ok for trunk?\n\n-- >8 --\nHere we are printing:\n\n  note: but ''lang_type' not supported by dump_expr<expression error>' is a type\n\nbecause we represent a null reflection with unknown_type_node.  Let's\ndetect splicing a null reflection.\n\ngcc/cp/ChangeLog:\n\n\t* reflect.cc (splice): Detect a null reflection.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/reflect/null6.C: New test.\n---\n gcc/cp/reflect.cc                    | 6 ++++++\n gcc/testsuite/g++.dg/reflect/null6.C | 8 ++++++++\n 2 files changed, 14 insertions(+)\n create mode 100644 gcc/testsuite/g++.dg/reflect/null6.C\n\n\nbase-commit: 7c84b2a62827b3509b25727694c9f0eac9e96b80\nprerequisite-patch-id: f332a4def1290bc364844d365a541cc651e461e1","diff":"diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc\nindex bcd43cf2ab6..59f8354a3cf 100644\n--- a/gcc/cp/reflect.cc\n+++ b/gcc/cp/reflect.cc\n@@ -8525,6 +8525,12 @@ splice (tree refl)\n       return error_mark_node;\n     }\n \n+  if (compare_reflections (refl, get_null_reflection ()))\n+    {\n+      error_at (loc, \"cannot splice a null reflection\");\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.  */\ndiff --git a/gcc/testsuite/g++.dg/reflect/null6.C b/gcc/testsuite/g++.dg/reflect/null6.C\nnew file mode 100644\nindex 00000000000..8b91ef756eb\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/null6.C\n@@ -0,0 +1,8 @@\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+using info = decltype(^^::);\n+constexpr auto null = info{};\n+constexpr auto q = [:null:];  // { dg-error \"cannot splice a null reflection\" }\n+[:null:] t1;\t\t      // { dg-error \"cannot splice a null reflection|expected\" }\n+[:null:]<int> t2;\t      // { dg-error \"cannot splice a null reflection|expected\" }\n","prefixes":["v2"]}