public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8444] c++: _Complex template parameter [PR100634]
@ 2021-05-20 3:12 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-05-20 3:12 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b54e50285c716fabc3980c5383c4898018a60b28
commit r11-8444-gb54e50285c716fabc3980c5383c4898018a60b28
Author: Jason Merrill <jason@redhat.com>
Date: Wed May 19 17:33:21 2021 -0400
c++: _Complex template parameter [PR100634]
We were crashing because invalid_nontype_parm_type_p allowed _Complex
template parms, but convert_nontype_argument didn't know what to do for
them. Let's just disallow it, people can and should use std::complex
instead.
PR c++/100634
gcc/cp/ChangeLog:
* pt.c (invalid_nontype_parm_type_p): Return true for COMPLEX_TYPE.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/nontype-complex1.C: New test.
Diff:
---
gcc/cp/pt.c | 2 ++
gcc/testsuite/g++.dg/cpp2a/nontype-complex1.C | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d30876ced9c..1434beb80f4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -26620,6 +26620,8 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain)
else if (cxx_dialect >= cxx11
&& TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM)
return false;
+ else if (TREE_CODE (type) == COMPLEX_TYPE)
+ /* Fall through. */;
else if (VOID_TYPE_P (type))
/* Fall through. */;
else if (cxx_dialect >= cxx20)
diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-complex1.C b/gcc/testsuite/g++.dg/cpp2a/nontype-complex1.C
new file mode 100644
index 00000000000..4de2168ef60
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/nontype-complex1.C
@@ -0,0 +1,8 @@
+// PR c++/100634
+// { dg-do compile { target c++20 } }
+// { dg-options "" }
+
+// We could support _Complex template arguments, but better I think to make
+// people use a standard type instead.
+template<_Complex int> struct ComplexInt {}; // { dg-error "not a valid type" }
+using CI = ComplexInt<1 + 3i>;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-20 3:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20 3:12 [gcc r11-8444] c++: _Complex template parameter [PR100634] Jason Merrill
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).