[{"id":3677305,"web_url":"http://patchwork.ozlabs.org/comment/3677305/","msgid":"<70fc703f-14cb-4a7c-8c48-f373b8ec9fb2@redhat.com>","list_archive_url":null,"date":"2026-04-14T16:23:25","subject":"Re: [PATCH] c++: introduce function_template_p","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On 4/14/26 10:17 AM, Marek Polacek wrote:\n> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?\n> \n> -- >8 --\n> As discussed in\n> <https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712156.html>,\n> this patch introduces a new predicate to be used instead of\n> really_overloaded_fn when we're checking for a function template.\n\nThis name is rather misleading for uses outside of reflection, given \nthat it will return true for an overload set that contains two \nnon-templates.  Let's include some form of \"reflection\" in the function \nname.\n\n> gcc/cp/ChangeLog:\n> \n> \t* cp-tree.h (function_template_p): Declare.\n> \t* parser.cc (cp_parser_splice_expression): Use function_template_p\n> \tinstead of really_overloaded_fn.\n> \t* reflect.cc (check_splice_expr): Likewise.\n> \t* tree.cc (function_template_p): New.\n> ---\n>   gcc/cp/cp-tree.h  | 1 +\n>   gcc/cp/parser.cc  | 2 +-\n>   gcc/cp/reflect.cc | 4 ++--\n>   gcc/cp/tree.cc    | 8 ++++++++\n>   4 files changed, 12 insertions(+), 3 deletions(-)\n> \n> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h\n> index 1080203ac8a..e2466f195fa 100644\n> --- a/gcc/cp/cp-tree.h\n> +++ b/gcc/cp/cp-tree.h\n> @@ -8722,6 +8722,7 @@ extern tree lookup_maybe_add\t\t\t(tree fns, tree lookup,\n>   \t\t\t\t\t\t bool deduping);\n>   extern int is_overloaded_fn\t\t\t(tree) ATTRIBUTE_PURE;\n>   extern bool really_overloaded_fn\t\t(tree) ATTRIBUTE_PURE;\n> +extern bool function_template_p\t\t\t(tree) ATTRIBUTE_PURE;\n>   extern tree dependent_name\t\t\t(tree);\n>   extern tree call_expr_dependent_name\t\t(tree);\n>   extern tree maybe_get_fns\t\t\t(tree) ATTRIBUTE_PURE;\n> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc\n> index 9dbc2933e7b..53672b348c3 100644\n> --- a/gcc/cp/parser.cc\n> +++ b/gcc/cp/parser.cc\n> @@ -6341,7 +6341,7 @@ cp_parser_splice_expression (cp_parser *parser, bool template_p,\n>         && (targs_p\n>   \t  /* No 'template' but the splice-specifier designates a function\n>   \t     template?  */\n> -\t  || really_overloaded_fn (t))\n> +\t  || function_template_p (t))\n>         && warning_enabled_at (loc, OPT_Wmissing_template_keyword))\n>       /* Were 'template' present, this would be valid code, so keep going.  */\n>       missing_template_diag (loc, diagnostics::kind::pedwarn);\n> diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc\n> index 4ef340f0726..91e4b9a364e 100644\n> --- a/gcc/cp/reflect.cc\n> +++ b/gcc/cp/reflect.cc\n> @@ -8978,7 +8978,7 @@ check_splice_expr (location_t loc, location_t start_loc, tree t,\n>   \t template.  */\n>         if (!targs_p)\n>   \t{\n> -\t  if (!really_overloaded_fn (t) && !dependent_splice_p (t))\n> +\t  if (!function_template_p (t) && !dependent_splice_p (t))\n>   \t    {\n>   \t      if (complain_p)\n>   \t\t{\n> @@ -9005,7 +9005,7 @@ check_splice_expr (location_t loc, location_t start_loc, tree t,\n>   \t    }\n>   \t  return false;\n>   \t}\n> -      gcc_checking_assert (really_overloaded_fn (t)\n> +      gcc_checking_assert (function_template_p (t)\n>   \t\t\t   || get_template_info (t)\n>   \t\t\t   || TREE_CODE (t) == TEMPLATE_ID_EXPR\n>   \t\t\t   || variable_template_p (t)\n> diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc\n> index 15dc8025f1b..48108027523 100644\n> --- a/gcc/cp/tree.cc\n> +++ b/gcc/cp/tree.cc\n> @@ -2764,6 +2764,14 @@ really_overloaded_fn (tree x)\n>     return is_overloaded_fn (x) == 2;\n>   }\n>   \n> +/* Returns true iff X is a function template.  */\n> +\n> +bool\n> +function_template_p (tree x)\n> +{\n> +  return really_overloaded_fn (x);\n> +}\n> +\n>   /* Get the overload set FROM refers to.  Returns NULL if it's not an\n>      overload set.  */\n>   \n> \n> base-commit: 31b012f7606ce7de82442e723ee62c05842c0f76","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=L2I60lUD;\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=L2I60lUD","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\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 4fw8jc3r2Bz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 02:24:03 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 5E8A74BA2E28\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 16:24:01 +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 5FCC24BA2E28\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 16:23:33 +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-664-JiZ3VSmANo6yfpmL_y_ZJA-1; Tue, 14 Apr 2026 12:23:29 -0400","by mail-qv1-f69.google.com with SMTP id\n 6a1803df08f44-8aca172588cso81068386d6.0\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 09:23:29 -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 6a1803df08f44-8ace991f419sm26858306d6.21.2026.04.14.09.23.26\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Tue, 14 Apr 2026 09:23:26 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 5E8A74BA2E28","OpenDKIM Filter v2.11.0 sourceware.org 5FCC24BA2E28"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 5FCC24BA2E28","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 5FCC24BA2E28","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776183813; cv=none;\n b=UsFq1EpRiv8JYxEw5xtK7In4c29VW7CxrXsyQ74tmqTm75l0l6hj+9CBk31eTvUtR1SuSKzibhJtqvbhgvY6WcpUHI4HN8z7MJ0Zas9sbNb27FIbaRGrMViK8a3/KaJqLzRBaxtq9GhSHiS7kpsJuItEtufCmv8NnjOW5rk4O9g=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776183813; c=relaxed/simple;\n bh=DQ2N8Z2f+PLT8JR0edsLDMOQpqToUWeCeN44rGfixxo=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=BGau0lKPlm0eIQg8Ug8j0Lkx1EHSMs1X0qvCuBaKx0phRyCD75yNoEp4X+PEe+F2V6nCbvxOgX8yuzMKyvwGqxRD/zC/uAP3iJFMm/G7tovJyM/GjN38JPyC8UQc7Z7v8PWl34L+FuqaUAyGw1NdqNWiFhcRvtFCpTQYicp8lE8=","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=1776183813;\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=ZCOgOR5/ByPAyP5jp+fbPiFIxGh0ayUH3oiUivtcGE0=;\n b=L2I60lUDPbqpZVPFJ6Niw7m7BNHBK73q5ZVqDY842XW4tuggwQJXXH4hIU7L0lBbTmk4JR\n 19wkbSE3pHaULpKdgRhZh7ymoaqEIePOUobKPDtjOvHiED/fsNRitlL64lCy2OoDuls+M6\n fkE3r/tVBD9QTZTefgy9f+zod5nkcVg=","X-MC-Unique":"JiZ3VSmANo6yfpmL_y_ZJA-1","X-Mimecast-MFC-AGG-ID":"JiZ3VSmANo6yfpmL_y_ZJA_1776183809","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776183808; x=1776788608;\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;\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ccBfFfcfXuCRwxUnRVWselrP1q84y2g9B1+N8EGdQcXfbbgXS6gQZs5R1J4kl\n Tlcmr8Y0KzmpqNUrVicJFuyu9VrdrSFRv7Lz2sZHzvb1fbOMErmHS7ghl9CtvStgHpOp4Uw2F8Z\n viL+gwDEVMnu66MZMDJK9diHCwm7L41iwEH3lAkRUsnQ==","X-Received":["by 2002:a05:6214:2c09:b0:89a:116b:e674 with SMTP id\n 6a1803df08f44-8ac861ad39dmr269949176d6.20.1776183807900;\n Tue, 14 Apr 2026 09:23:27 -0700 (PDT)","by 2002:a05:6214:2c09:b0:89a:116b:e674 with SMTP id\n 6a1803df08f44-8ac861ad39dmr269948496d6.20.1776183807327;\n Tue, 14 Apr 2026 09:23:27 -0700 (PDT)"],"Message-ID":"<70fc703f-14cb-4a7c-8c48-f373b8ec9fb2@redhat.com>","Date":"Tue, 14 Apr 2026 12:23:25 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++: introduce function_template_p","To":"Marek Polacek <polacek@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>","References":"<20260414141710.99666-1-polacek@redhat.com>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<20260414141710.99666-1-polacek@redhat.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"Rx_0msSRGM1lyTPgGVJ814qKsmdTEVSHKPwrNxCj1As_1776183809","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"}}]