[{"id":3678900,"web_url":"http://patchwork.ozlabs.org/comment/3678900/","msgid":"<18c81c0b-da77-4423-960f-3c5e88bf336b@redhat.com>","list_archive_url":null,"date":"2026-04-17T21:57:42","subject":"Re: [PATCH] c++/reflection: support splices with CTAD [PR124706]","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On 4/17/26 4:28 PM, Marek Polacek wrote:\n> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?\n\nOK.\n\n> -- >8 --\n> This PR points out that we don't handle a splice-type-spec that\n> designates a deducible template, which then serves as a placeholder\n> for CTAD.  This is allowed by [dcl.type.simple]/3.  This patch\n> fixes that problem by calling make_template_placeholder if we\n> get a deducible template.\n> \n> \tPR c++/124706\n> \n> gcc/cp/ChangeLog:\n> \n> \t* parser.cc (cp_parser_splice_type_specifier): For ctad_template_p\n> \tcall make_template_placeholder.\n> \n> gcc/testsuite/ChangeLog:\n> \n> \t* g++.dg/reflect/error10.C: Adjust dg-error.\n> \t* g++.dg/reflect/ctad1.C: New test.\n> \t* g++.dg/reflect/ctad2.C: New test.\n> ---\n>   gcc/cp/parser.cc                       |  6 ++++++\n>   gcc/testsuite/g++.dg/reflect/ctad1.C   | 13 +++++++++++++\n>   gcc/testsuite/g++.dg/reflect/ctad2.C   | 24 ++++++++++++++++++++++++\n>   gcc/testsuite/g++.dg/reflect/error10.C |  5 ++---\n>   4 files changed, 45 insertions(+), 3 deletions(-)\n>   create mode 100644 gcc/testsuite/g++.dg/reflect/ctad1.C\n>   create mode 100644 gcc/testsuite/g++.dg/reflect/ctad2.C\n> \n> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc\n> index cc59065848a..9f2641f2ab2 100644\n> --- a/gcc/cp/parser.cc\n> +++ b/gcc/cp/parser.cc\n> @@ -6258,6 +6258,12 @@ cp_parser_splice_type_specifier (cp_parser *parser)\n>     if (dependent_splice_p (type))\n>       return make_splice_scope (type, /*type_p=*/true);\n>   \n> +  /* [dcl.type.simple]/3: A type-specifier is a placeholder for a deduced\n> +     class type if [...] it is of the form typename[opt] splice-specifier and\n> +     the splice-specifier designates a class template or alias template.  */\n> +  if (ctad_template_p (type))\n> +    type = make_template_placeholder (type);\n> +\n>     if (!valid_splice_type_p (type))\n>       {\n>         if (!cp_parser_simulate_error (parser))\n> diff --git a/gcc/testsuite/g++.dg/reflect/ctad1.C b/gcc/testsuite/g++.dg/reflect/ctad1.C\n> new file mode 100644\n> index 00000000000..5358b584bc8\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/reflect/ctad1.C\n> @@ -0,0 +1,13 @@\n> +// PR c++/124706\n> +// { dg-do compile { target c++26 } }\n> +// { dg-additional-options \"-freflection\" }\n> +\n> +template <class T> struct X;\n> +template <> struct X<int> {\n> +    constexpr X(int) {}\n> +};\n> +X(int) -> X<int>;\n> +\n> +static constexpr auto template_info = ^^X;\n> +\n> +[:template_info:] y{ 13 };\n> diff --git a/gcc/testsuite/g++.dg/reflect/ctad2.C b/gcc/testsuite/g++.dg/reflect/ctad2.C\n> new file mode 100644\n> index 00000000000..21f07a419b9\n> --- /dev/null\n> +++ b/gcc/testsuite/g++.dg/reflect/ctad2.C\n> @@ -0,0 +1,24 @@\n> +// PR c++/124706\n> +// { dg-do compile { target c++26 } }\n> +// { dg-additional-options \"-freflection\" }\n> +\n> +template <class T>\n> +struct A\n> +{\n> +  A(T);\n> +};\n> +[:^^A:] a(42);\n> +typename [:^^A:] a2(42);\n> +\n> +template<typename T> struct B { T x; };\n> +[:^^B:] b{0};\n> +typename [:^^B:] b2{0};\n> +\n> +template<class T, class U>\n> +struct X { X(U) {} };\n> +\n> +template<class U>\n> +using Y = X<void, U>;\n> +\n> +[:^^Y:] y{1};\n> +typename [:^^Y:] y2{1};\n> diff --git a/gcc/testsuite/g++.dg/reflect/error10.C b/gcc/testsuite/g++.dg/reflect/error10.C\n> index 891a643c1a0..1ac171c73cc 100644\n> --- a/gcc/testsuite/g++.dg/reflect/error10.C\n> +++ b/gcc/testsuite/g++.dg/reflect/error10.C\n> @@ -39,8 +39,7 @@ template<int>\n>   struct S {};\n>   \n>   void\n> -fn5 (int, typename [: ^^S :] i) // { dg-error \"expected a reflection of a type|declared\" }\n> -// { dg-message \"but .S. is a class template\" \"\" { target *-*-* } 39 }\n> +fn5 (int, typename [: ^^S :] i) // { dg-error \"template placeholder not permitted in parameter\" }\n>   {\n>   }\n>   \n> @@ -49,6 +48,6 @@ void bar ();\n>   \n>   void\n>   fn6 (int, typename [: ^^bar :] i) // { dg-error \"expected a reflection of a type|declared\" }\n> -// { dg-message \"but .bar. is a function template\" \"\" { target *-*-* } 48 }\n> +// { dg-message \"but .bar. is a function template\" \"\" { target *-*-* } 47 }\n>   {\n>   }\n> \n> base-commit: 957c1153f5eedbbab8be92c5805d2cf53a84b204","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=id+kN6ym;\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=id+kN6ym","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 4fy7zs0bJpz1y1V\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 07:58:17 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id F2F1D4D108E1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 21:58:14 +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 F12B14D108DE\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 21:57:46 +0000 (GMT)","from mail-qv1-f71.google.com (mail-qv1-f71.google.com\n [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-611-hH7mlKy6Ps-mIiXgTrVd5w-1; Fri, 17 Apr 2026 17:57:45 -0400","by mail-qv1-f71.google.com with SMTP id\n 6a1803df08f44-8acadca1ac4so37257616d6.0\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 14:57:45 -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-8b02aeb04e0sm19738166d6.46.2026.04.17.14.57.42\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Fri, 17 Apr 2026 14:57:43 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org F2F1D4D108E1","OpenDKIM Filter v2.11.0 sourceware.org F12B14D108DE"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org F12B14D108DE","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org F12B14D108DE","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776463067; cv=none;\n b=BS7eNAizpnvGQOQx+xecBIGwS4UAeDcJBZMnn1HDwgQVJNPD7UjCiqEIwjewuyEqUXq6Und4Z2a6SQlu3Chnaib02+fSP8sm1M5C8cTvws2fkuj8S9NN3dswCCYT4UA1y6JXSWoFhTmrKcXqQ5QBa8WJd/qqz6hLh05N6VLNfOE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776463067; c=relaxed/simple;\n bh=2YDsO4UHW+rf/LGXg4xb+nmgCWgtRWClXoZ0z+Ja55o=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=uFBh1rMlsBD+tDcBy5Er6TrA7YdYYc/rY9lfnNPCx2nV6xP2y7iiIAEcyBimM80VrT2Ic04SEka+uWGycwXV56LmiLKfoFyHnJ50r8mJk/2J7namB3ikUzcUqWjnOEsJ4CF9O0YdVzyHlSYJrc5RYUvfi4tb8pZChq9mwmzKn4Q=","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=1776463066;\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=Sap89q1Pbb263Y1Zgefo49lU2wYlryzXt21sfHmqw6E=;\n b=id+kN6ymatJnSl9GnbuRKWbj8E2Lq//jxB7AA2Orz1Rgh0QKx4QUmqm5jyvhazY7QJIlcg\n BPB7py/7pkMcq3QRS4TDUjM+uL9bngZCHMf9UWWVlIDDNw1wOJiPRFejQR/ap27vHBAXKS\n 2aOvlkoX7TqAYM9A+cILZNlBf3Tcy6s=","X-MC-Unique":"hH7mlKy6Ps-mIiXgTrVd5w-1","X-Mimecast-MFC-AGG-ID":"hH7mlKy6Ps-mIiXgTrVd5w_1776463064","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776463064; x=1777067864;\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=Sap89q1Pbb263Y1Zgefo49lU2wYlryzXt21sfHmqw6E=;\n b=YyUceK2yKo1OMtaYBHaTwbMRFM/pc0kkgeAZ/RyWPs5jKx8gf8/+iNHYcZygQKZP7z\n ZsMhzJNuBw2lGvBvaX5oBOx9Tpf+GI0tGNq85/TlkAFiSsylYQcSD3rpjLlFrvGv+k8/\n mynB3yvHsRm9DsSz/KPgAWOrRkWlBaOTU15adasxqhlvqXy8vI2Rm5DqzOxmL5gEp2cR\n u/PYHUfRLTSdbDS4AxyuzeNam5Go2sertIDdrwAdtTV/vBNTI9Q7vq2VPIjHTI8MUSqH\n hxc2/DF/Da79Ztr4RGRRLG/LLv3AH20jF9gjM0uly26zxlIIsz8AuFMNCYkLlLkJnilx\n ZOcA==","X-Forwarded-Encrypted":"i=1;\n AFNElJ/bzeEjKbz5As7b1JgKIewLDzWufn0CZ8+lAKc7qxlNhPzX3pRj5k4L954LZW1LHDSqN30tesCtbA6DaQ==@gcc.gnu.org","X-Gm-Message-State":"AOJu0YyhpWmt94Gd/b/FlELrgGq5L2ox50UKI/0pWAMik9f51SABXGbo\n 14xtE6nYdmu2nCPpX+PK+JeAAWtm4jMUxoxi4PujFFcqJ96JG1tNDypxa5Rhzw79yzRhehFKQpF\n 9eZdCPuVA1qOotZJzq/OKiqfoBzHqNyJSDdAismg19QPFaGzN1YDt/81NTzU=","X-Gm-Gg":"AeBDieunIRIS0yTNN10zIyV6pxWI1u9BEfkgOz59a380s972LX6YuqpkrsyI/z24jrR\n 72vLyAVZvTGV81xq8Sn+thjvB0gXDoWBZPhbzoWYX15awxunuuHImYSwxtQ6VsGbKnki+CEdB4Q\n qwudkNcrMlfAQyNk7ZtphNYghb/egYbnPQ2aPlfEFMKp3dzfLb4nAeP/hBL30T2DTbNoaCil/nR\n Hy50c07FM4rQhLa586Ms7+pBvGFeclaUJpnpybM/iD+y30fuVL/NvdkAweWiqJyRjDtP4ERW4yT\n wFpsRyQYXor74u8MIIo14apfE/y75jGGbvrT+CeMH7Mo94jKLqey9nNapK30qIs99IA46vmptS3\n A8/OrUfSm5IjQFtDhz664dUA2lAJkmiGCIlqwce6PjDjLuWtm/9phB3oE92CMaUSkcIio3ZKjEG\n pxBUJs8rRHIpFoBfezlarAR+xtAoNIO0CdDDKyPe6xnQ==","X-Received":["by 2002:a05:6214:588e:b0:8ac:a48a:a586 with SMTP id\n 6a1803df08f44-8b02803f167mr77092486d6.14.1776463064491;\n Fri, 17 Apr 2026 14:57:44 -0700 (PDT)","by 2002:a05:6214:588e:b0:8ac:a48a:a586 with SMTP id\n 6a1803df08f44-8b02803f167mr77092056d6.14.1776463063899;\n Fri, 17 Apr 2026 14:57:43 -0700 (PDT)"],"Message-ID":"<18c81c0b-da77-4423-960f-3c5e88bf336b@redhat.com>","Date":"Fri, 17 Apr 2026 17:57:42 -0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] c++/reflection: support splices with CTAD [PR124706]","To":"Marek Polacek <polacek@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>","References":"<20260417202807.373863-1-polacek@redhat.com>","From":"Jason Merrill <jason@redhat.com>","In-Reply-To":"<20260417202807.373863-1-polacek@redhat.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"SDtqD7qJMKFlj7Wn87bWLSD-5PHqrf0CzRKn_RHJRCA_1776463064","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"}}]