public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Alex Coplan <acoplan@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] cp: Allow converted constant expressions to INTCAP_TYPE Date: Tue, 22 Nov 2022 22:18:41 +0000 (GMT) [thread overview] Message-ID: <20221122221841.E26613858C1F@sourceware.org> (raw) https://gcc.gnu.org/g:605b79c1e1a10a565d42070f5069c7167fd52ec4 commit 605b79c1e1a10a565d42070f5069c7167fd52ec4 Author: Alex Coplan <alex.coplan@arm.com> 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>(); }
reply other threads:[~2022-11-22 22:18 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221122221841.E26613858C1F@sourceware.org \ --to=acoplan@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).