* C++ PATCH for c++/45473 (ICE with base virtual function named the same as derived class)
@ 2010-11-06 1:46 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2010-11-06 1:46 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 411 bytes --]
In this testcase, we've always (at least as far back as 2.95) treated
B::B() as overriding A::B(), which is wrong; constructors do not have
names, so they cannot have the same name as a virtual function.
I was worried that this was going to be an ABI issue, but fortunately
the testcase never actually compiled; past GCC versions emitted
ill-formed assembly.
Tested x86_64-pc-linux-gnu, applied to trunk.
[-- Attachment #2: 45473.patch --]
[-- Type: text/plain, Size: 938 bytes --]
commit 650267e2d691dd2c42049a0214a6f691e72cb8e3
Author: Jason Merrill <jason@redhat.com>
Date: Fri Nov 5 20:40:28 2010 -0400
PR c++/45473
* search.c (look_for_overrides): A constructor is never virtual.
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 0249fb0..76bf47c 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1935,6 +1935,9 @@ look_for_overrides (tree type, tree fndecl)
int ix;
int found = 0;
+ if (DECL_CONSTRUCTOR_P (fndecl))
+ return 0;
+
for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
{
tree basetype = BINFO_TYPE (base_binfo);
diff --git a/gcc/testsuite/g++.dg/inherit/virtual6.C b/gcc/testsuite/g++.dg/inherit/virtual6.C
new file mode 100644
index 0000000..f036969
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/virtual6.C
@@ -0,0 +1,15 @@
+// PR c++/45473
+
+struct A
+{
+ virtual void B ();
+};
+
+struct B : A
+{
+ B ();
+};
+
+struct C : B
+{
+};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-11-06 1:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-06 1:46 C++ PATCH for c++/45473 (ICE with base virtual function named the same as derived class) 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).