[{"id":3678178,"web_url":"http://patchwork.ozlabs.org/comment/3678178/","msgid":"<05317d8e-be32-4c67-8d50-becc3864e65e@redhat.com>","list_archive_url":null,"date":"2026-04-16T13:40:47","subject":"Re: [PATCH] c++/reflection: null reflection in inform_tree_category","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"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\nCan we diagnose sooner trying to splice a null reflection?  That should \nbe ill-formed regardless of whether we expect it to be a type or \nexpression or whatever.\n\n> gcc/cp/ChangeLog:\n> \n> \t* error.cc (inform_tree_category): Don't print unknown_type_node.\n> \n> gcc/testsuite/ChangeLog:\n> \n> \t* g++.dg/reflect/null6.C: New test.\n> ---\n>   gcc/cp/error.cc                      | 2 +-\n>   gcc/testsuite/g++.dg/reflect/null6.C | 8 ++++++++\n>   2 files changed, 9 insertions(+), 1 deletion(-)\n>   create mode 100644 gcc/testsuite/g++.dg/reflect/null6.C\n> \n> diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc\n> index b3e66924e31..f0097bf6808 100644\n> --- a/gcc/cp/error.cc\n> +++ b/gcc/cp/error.cc\n> @@ -3988,7 +3988,7 @@ inform_tree_category (tree t)\n>     if (TREE_CODE (t) == TYPE_DECL)\n>       t = TREE_TYPE (t);\n>   \n> -  if (TYPE_P (t))\n> +  if (TYPE_P (t) && t != unknown_type_node)\n>       inform (loc, \"but %qE is a type\", t);\n>     else if (EXPR_P (t))\n>       inform (loc, \"but %qE is an expression\", t);\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..55bf15ef959\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 \"expected a reflection of an expression\" }\n> +// { dg-message \"add .typename.\" \"\" { target *-*-* } .-1 }\n> +// { dg-bogus \"is a type\" \"\" { target *-*-* } .-2 }\n> \n> base-commit: 77d4080e1e5f9d467816e2e2e878edbfbb7ee1c1","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=GMxDp8ih;\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=GMxDp8ih","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 4fxK101Fnbz1yHP\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 23:41:22 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id C346F4BA23E2\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 13:41:20 +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 0FB4D4BA2E35\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 13:40:53 +0000 (GMT)","from mail-qt1-f197.google.com (mail-qt1-f197.google.com\n [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-193-FiPRFPXTObSHrEDjF3ZpNQ-1; Thu, 16 Apr 2026 09:40:51 -0400","by mail-qt1-f197.google.com with SMTP id\n d75a77b69052e-50d84b5f73bso186344181cf.0\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 06:40:51 -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-50e1b016a2asm47844391cf.31.2026.04.16.06.40.48\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Thu, 16 Apr 2026 06:40:48 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org C346F4BA23E2","OpenDKIM Filter v2.11.0 sourceware.org 0FB4D4BA2E35"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 0FB4D4BA2E35","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 0FB4D4BA2E35","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776346853; cv=none;\n b=d1GOJClGRRfYPHzy5IBqPLeyk7CndHnOd1YgLv5JAdCCkJsZ7cYLYOR6FRgGHkct4AmtHKwRg76g8iee2RjxN/EAmSVxdowTnr59Y12qf4RbShyjKVk30UuVnRLIbdgu16IpFOXq7JdgZBH2k3TVcGjmftV9DU5ivig8SmT6POI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776346853; c=relaxed/simple;\n bh=ahblc2CSny1Nm/ffAWlprSHNxnAXkbj8CdG8PLnTPOo=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=S4IWD56E2QoTWChnGpciJQnqjunQ3+ClyurNCyiySxo9hObJHY0e69Kc6XbPC6a7/nKpLrnMhv66BMDzKtu2DP/6HizijHndHSMcWdJwURZsMU2E8RORhlwZpkMOsS/5yDQ7vas9YXXOcaVtW/IgM9GUDOo6uJ0sBFDcJWQzAco=","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=1776346852;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to: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=GKlklKEYOPYFI6ChrldjH8N+pm2Bwu6EZZYYeOx+hd8=;\n b=GMxDp8ihcR2g+CkvYerZ8oKIxaYjyE295OtVrB73Z7GdG5xla0hNdkqmN4kwZKfvFA8Aep\n ZEkzQYHoFmbDzM4kePQ3VQMhfV03Oj4JESNoneLHmseug8u/E3TqdsXz7puQanj/PEE3Jo\n ilhHUhPjfGhhm5/ilUtp/gpf8RvVGy0=","X-MC-Unique":"FiPRFPXTObSHrEDjF3ZpNQ-1","X-Mimecast-MFC-AGG-ID":"FiPRFPXTObSHrEDjF3ZpNQ_1776346850","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776346850; x=1776951650;\n h=content-transfer-encoding:in-reply-to:from:content-language\n :references: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=GKlklKEYOPYFI6ChrldjH8N+pm2Bwu6EZZYYeOx+hd8=;\n b=lC63B1zkRS/hzBpTTTAXy3lC9gUJPGJ/R0SxZ5lBS4MUYH9yGNpIBoD1j1/8ySyaKK\n 0Ut1fMJuq5VZZz/XMHZI7+KKB2NECxZ/9psGLc6CAkrOC3oRZWkOCPHsrm8lUsr/aMxy\n /eL8df7JOSegLEQ2KyzndaBf78PmRzxWPUL2WY+3eEYIv0hD2eLf4NNP8fpwzJDSFkZ2\n ChMg2Nr0NPFgioerQmivBo1a2fjqZDTY+/C1eT8+CjOLNJs9D9fwCK0nkh1lCvbRARWI\n BTBfM0gozADiSjZ3yQdlQCgzqm13TsBnH5Q/ZBwcHJjW+qIn9ByRowljDCS46PLPT0B6\n Wgzw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ9mg2/sKo71u/9ySs3wToi5nhE0EZos+VP38uqY/YBcQeKsFcdrSwi6wxfLS+LPrfP5kaSRl0+RDjuR0Q==@gcc.gnu.org","X-Gm-Message-State":"AOJu0YxD0YSnUXpFaJgXRWN+saGKdDEykVRW9dTNTygE0gFBFwiRufL8\n 1LD4Y1TIjJHrydjX2uo0riG48Ojk7gp4XgaluCFW9p/XPZ0UVf5nADQOBVSALRKTCJtGHGckhH7\n dAqIwN0DwGMi61ITHMZBiezswb3aiBc3DCMc6NG9/DORlJIIFa0vkiYYcOvE=","X-Gm-Gg":"AeBDieupHTOJiqK549ZrBaD4NOiDWF/XL8W9RnQoYFPm2wbf+8fzZd7z6wUVyNQA+WP\n nHPNxlKLRAJ6jfzJT5fBVvXhcAMsAAwHNEerUY5fzAjccrvP+/Fga0teYDWOdMPc/MFcQhiHUre\n uN09c56k79NHHC19W3e2ZuGlATEZLjCyKu/M87cAHawXYv+TgD26oDItKzvB5GrWfDhRmGguMlm\n aejycUxxQm6wfBpetrByllGL1B5YlUwXTjLTlm1RMUVXcSUnVRP/qZx8Y0n9bDX38mj51LA8ZON\n KQmFy92gVQg/Y1JTZG5NhuSFFsIMkPtSNu1CnM92egidg/xyFXqZAbkGn/fLFr1JhnedX6S9mPi\n XhTcmlJZ5bbLCY//WMvOohROYJZ28tSpcLKh8x9Wt9WXB/6dV/iAIoZ9ID+Hs/LYk8hubWVXVTE\n dVHXlk+viZ6LuaC572zQBegHfocAhksuAxahpPrx5Xmg==","X-Received":["by 2002:a05:622a:229e:b0:50d:3efd:bd9b with SMTP id\n d75a77b69052e-50dd5b78984mr395629731cf.23.1776346850572;\n Thu, 16 Apr 2026 06:40:50 -0700 (PDT)","by 2002:a05:622a:229e:b0:50d:3efd:bd9b with SMTP id\n d75a77b69052e-50dd5b78984mr395628301cf.23.1776346849412;\n Thu, 16 Apr 2026 06:40:49 -0700 (PDT)"],"Message-ID":"<05317d8e-be32-4c67-8d50-becc3864e65e@redhat.com>","Date":"Thu, 16 Apr 2026 09:40:47 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++/reflection: null reflection in inform_tree_category","To":"Marek Polacek <polacek@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>","References":"<20260415235200.1576761-1-polacek@redhat.com>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<20260415235200.1576761-1-polacek@redhat.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"j86Z3422-dgGox_tfwvQdCiPU-A4ohdcs2R1T60kgkg_1776346850","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"}}]