From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id E26613858C1F; Tue, 22 Nov 2022 22:18:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E26613858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669155521; bh=E/01yeCvq9n6zzilxmPALwgBfUw8miAJu5FGYP5Pxas=; h=From:To:Subject:Date:From; b=cAUmJlq7AiWnzLnlJfdgLqvc/J6AR8h1Mw/BGSzkiDllO18rp77KH/imBboBUDt/s Draz5SURCTkLs6bQnNKGifQGw+dcrGfo8LFg+bEvNUWMbMyMEL1wqNFo/V7VjpryD5 lD0IZwvBk0xtxo6krHAagsnUUTaCIWkt5ud4IoHY= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alex Coplan To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] cp: Allow converted constant expressions to INTCAP_TYPE X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 0aefaf8fd036923367eb7484cab4a6a8ff01436e X-Git-Newrev: 605b79c1e1a10a565d42070f5069c7167fd52ec4 Message-Id: <20221122221841.E26613858C1F@sourceware.org> Date: Tue, 22 Nov 2022 22:18:41 +0000 (GMT) List-Id: https://gcc.gnu.org/g:605b79c1e1a10a565d42070f5069c7167fd52ec4 commit 605b79c1e1a10a565d42070f5069c7167fd52ec4 Author: Alex Coplan Date: Tue Nov 15 17:53:03 2022 +0000 cp: Allow converted constant expressions to INTCAP_TYPE This allows conversions between intcap and integer types in both directions in the context of converted constant expressions. There was an unjustified asymmetry in how we handled this before, causing the testcase added with this patch to be rejected. Diff: --- gcc/cp/call.c | 3 ++- gcc/cp/pt.c | 1 + gcc/testsuite/g++.dg/template/intptr-param.C | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index bd5dea9ed24..18990dcb359 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4417,7 +4417,8 @@ build_converted_constant_expr_internal (tree type, tree expr, t = next_conversion (c)->type; if ((INTEGRAL_OR_ENUMERATION_TYPE_P (t) || INTCAP_TYPE_P (t)) - && INTEGRAL_OR_ENUMERATION_TYPE_P (type)) + && (INTEGRAL_OR_ENUMERATION_TYPE_P (type) + || INTCAP_TYPE_P (type))) /* Integral promotion or conversion. */ break; if (NULLPTR_TYPE_P (t)) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9957c11034f..69d48892d25 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7213,6 +7213,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) to leave it in that form rather than lower it to a CONSTRUCTOR. */; else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type) + || INTCAP_TYPE_P (type) || cxx_dialect >= cxx17) { /* C++17: A template-argument for a non-type template-parameter shall diff --git a/gcc/testsuite/g++.dg/template/intptr-param.C b/gcc/testsuite/g++.dg/template/intptr-param.C new file mode 100644 index 00000000000..b9ca2a89a76 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/intptr-param.C @@ -0,0 +1,4 @@ +// { dg-do compile } +template<__INTPTR_TYPE__ x> +int f() { return x; } +int g() { return f<1>(); }