public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8438] c++: array of PMF [PR113598]
@ 2024-01-25 20:22 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2024-01-25 20:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:136a828754ff65079a834555582b49d54bd5bc64
commit r14-8438-g136a828754ff65079a834555582b49d54bd5bc64
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jan 25 12:02:07 2024 -0500
c++: array of PMF [PR113598]
Here AGGREGATE_TYPE_P includes pointers to member functions, which is not
what we want. Instead we should use class||array, as elsewhere in the
function.
PR c++/113598
gcc/cp/ChangeLog:
* init.cc (build_vec_init): Don't use {} for PMF.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-pmf2.C: New test.
Diff:
---
gcc/cp/init.cc | 4 +++-
gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C | 12 ++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index adbdfc2dbfce..ac37330527e6 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -4864,7 +4864,9 @@ build_vec_init (tree base, tree maxindex, tree init,
But for non-classes, that's the same as value-initialization. */
if (empty_list)
{
- if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type))
+ if (cxx_dialect >= cxx11
+ && (CLASS_TYPE_P (type)
+ || TREE_CODE (type) == ARRAY_TYPE))
{
init = build_constructor (init_list_type_node, NULL);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C
new file mode 100644
index 000000000000..0fac8333c753
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C
@@ -0,0 +1,12 @@
+// PR c++/113598
+// { dg-additional-options -Wno-c++11-extensions }
+
+struct Cpu
+{
+ int op_nop();
+};
+typedef int(Cpu::*OpCode)();
+void f()
+{
+ new OpCode[256]{&Cpu::op_nop};
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-25 20:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 20:22 [gcc r14-8438] c++: array of PMF [PR113598] 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).