[{"id":3678290,"web_url":"http://patchwork.ozlabs.org/comment/3678290/","msgid":"<dac6ba8a-3425-4993-8634-5a7aebe376b6@redhat.com>","list_archive_url":null,"date":"2026-04-16T17:29:29","subject":"Re: [PATCH] c++/reflection: splicing null reflection","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"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\nPlease also test null in a splice-type-specifier, with and without \ntemplate arguments.\n\nJason","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=d9JoTqNt;\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=d9JoTqNt","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 4fxQ4w1jLWz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 03:30:06 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id E0DA94BAD171\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 17:30:04 +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 CC3CB4BA2E26\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 17:29:37 +0000 (GMT)","from mail-qt1-f199.google.com (mail-qt1-f199.google.com\n [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-480-IsDmsgokOv-A1TcH8K0Jqw-1; Thu, 16 Apr 2026 13:29:33 -0400","by mail-qt1-f199.google.com with SMTP id\n d75a77b69052e-50e136aff17so12503241cf.3\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 10:29:33 -0700 (PDT)","from [192.168.50.130]\n (130-44-146-247.s12789.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com.\n [130.44.146.247]) by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-50e1afc597fsm42393721cf.24.2026.04.16.10.29.30\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Thu, 16 Apr 2026 10:29:30 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org E0DA94BAD171","OpenDKIM Filter v2.11.0 sourceware.org CC3CB4BA2E26"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org CC3CB4BA2E26","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org CC3CB4BA2E26","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776360577; cv=none;\n b=uDnUSq/Exzw804323T157/sSrTpuklpjIgx52duEBDzZRkhmWfw1GETN9Kq/peUdSfiSl6AxuAzyGQUXMFyYvA/RlHonGwnf5Sy70dGQbk3VICREmOH19ZUW4LNKnq7+grPkUrRcpwqnoezNFoObqvdgZPNWIPRphUoK97kHSQ4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776360577; c=relaxed/simple;\n bh=1Lj9ZCf8O2t5NYWIC/KmysuGdSVd6YkwbgSRbGy99kQ=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=GTKfUgGhEKgJ3B466y4qMlTVnOylXs6H3ejlkMQeVVOah6f33MuR/ohzPZXL4SH8w4byl6+1f5xHb5PWhaQLEHjoW9oBoFcN7Q74GQ+hXLtgmM6B7PqesVMJ4o2M4+EnGHFML7rm+8uMUVFN9GoXKh0Nd9n7TBLLPiCkRGkOgEk=","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=1776360577;\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 content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=S/D2b9owAkXN4PPHDaOFoBSFyraOYkxGu8I3eu4jiHA=;\n b=d9JoTqNtZ7bkVJVAx2zRExFWe4ozPNdABjFk9R8egz7hzOEOn7qEOhhkxO1b09Oo7+PjcL\n jcPVAKzCR9boKBddL16URsA23CUrNNmfGiNlwjsrin8fhswVEVmY1whbBx6Kh1w1Xyv6VL\n mgBkWf0N3j15sA/ekSGMaezBqgh95ag=","X-MC-Unique":"IsDmsgokOv-A1TcH8K0Jqw-1","X-Mimecast-MFC-AGG-ID":"IsDmsgokOv-A1TcH8K0Jqw_1776360572","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776360572; x=1776965372;\n h=content-transfer-encoding:in-reply-to:from:content-language\n :references:cc:to:subject:user-agent:mime-version:date:message-id\n :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=S/D2b9owAkXN4PPHDaOFoBSFyraOYkxGu8I3eu4jiHA=;\n b=Ww4waCu8Knpnk1ZoNZmfuOiVLL2CCOVYJjiuUzwOZrF8fuLOXiWRd9TEq5UYWXIHfw\n HBdJyJbNwezll7J9QZ2QGo9qZsaELnY45MsCLq8zBoFkdNQmqkyNOiCB4MUCDuxboGcZ\n OiTlANsOrH7OjuNiS8d0xMb5Smq4hLwHQsVT9ujpvpLLcUnCTB09w0K8qmIlDSEVAkxb\n GRqE0NFGOGeh5pe8eyBSZL2VqMMgbZEocBJmWyAtZHBa4+bHF61SKmc6Q+qqg82+Hxr2\n O+mUkGW9MqBYq8IGoa7y0VjD6aRO7iSyUMpv/WsTPqgqJCDsAlbPjnh/VRI29k4mhyvs\n k/gg==","X-Gm-Message-State":"AOJu0YzQ9Gjc0Fy0aTfw9iI4GGlUvg9YkkCbcInLrTeiqsKysrevIOiM\n bOIRt6SS2ATgWRXow4Po39dE6YrPI4ypLSKPWV5J98HfaHAhcRmaaHenFI8LoeBKmgcpbbioged\n XcO7DYwSmTYJOeyyHnGBgHZM/VlmqR0sa6PAxzNT+4y++uH6R09HLZR+VY+c=","X-Gm-Gg":"AeBDievWZvREWVxF3nJyV5Zjt3D9mjc2rOR46Y7gwm0zQhB/X8Y16f8bnfJDN+zH/ZT\n ZEbzQhXUt80kJ/C1gODnQCvyQqQohE5v94utrqM7dTxeAy9zQbTtZRdIwzFnQu4jfCk06VyWyj2\n /udU0/wN4f7sRxUCKucJ9yf00DXTFVIe/zPeVG4Mz2n36hr6tPhBTWnvgrSxcKsGwjNOu8o57hP\n ZFoftTewxjGHFj7LTEe1QN3W00kwhv+8Qpt/ueU5HtDuJoAo8QDcCGjwaIm4pUV0sqIaOAP2v34\n HI/cYKYbUBzjlKekqev2uWeOvpXp7fBzDGO0/8Wu7pFQAYd/f4MnWeVAgIHLAUe9ks7eHS+1XOY\n d0E3AmUNRUrRmSNiVWgDOky5RtgGzKLJ9vJxkEDNbVhfOR5pe46yK8snGxLjDD3Q6JfbIQaLFy6\n YhPFHv4WO79ukj16Zu4Py9s3LdyBeOT4z0xTHwbYiL+Q==","X-Received":["by 2002:a05:622a:2cb:b0:50b:3f6a:1d88 with SMTP id\n d75a77b69052e-50dd5b0fd23mr421568211cf.19.1776360572495;\n Thu, 16 Apr 2026 10:29:32 -0700 (PDT)","by 2002:a05:622a:2cb:b0:50b:3f6a:1d88 with SMTP id\n d75a77b69052e-50dd5b0fd23mr421567591cf.19.1776360571954;\n Thu, 16 Apr 2026 10:29:31 -0700 (PDT)"],"Message-ID":"<dac6ba8a-3425-4993-8634-5a7aebe376b6@redhat.com>","Date":"Thu, 16 Apr 2026 13:29:29 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++/reflection: splicing null reflection","To":"Marek Polacek <polacek@redhat.com>","Cc":"GCC Patches <gcc-patches@gcc.gnu.org>","References":"<20260415235200.1576761-1-polacek@redhat.com>\n <05317d8e-be32-4c67-8d50-becc3864e65e@redhat.com>\n <aeECjy5O6sXf2YA5@redhat.com>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<aeECjy5O6sXf2YA5@redhat.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"0C48aWrg-8l2t0m3rp-rpWYoSz-L0CVQZmfu3cBBlGQ_1776360572","X-Mimecast-Originator":"redhat.com","Content-Language":"en-US","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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"}}]