aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-01-22 11:57:27 -0500
committerJason Merrill <jason@redhat.com>2021-01-22 13:09:00 -0500
commit90cbc769006a43ed17d2384b3a0a4634f315d3fd (patch)
tree3d06f73f4cdba6e1ca5fdbdeeb8546808d609262 /gcc
parenta9ed18295bfc6d69d40af197e059e16622cd94c6 (diff)
downloadgcc-90cbc769006a43ed17d2384b3a0a4634f315d3fd.zip
gcc-90cbc769006a43ed17d2384b3a0a4634f315d3fd.tar.gz
gcc-90cbc769006a43ed17d2384b3a0a4634f315d3fd.tar.bz2
c++: Fix base copy elision thinko [PR98744]
As Jakub points out in the PR, I was mixing up DECL_HAS_IN_CHARGE_PARM_P (which is true for the abstract maybe-in-charge constructor) and DECL_HAS_VTT_PARM_P (which is true for a base constructor that needs to handle virtual bases). gcc/cp/ChangeLog: PR c++/98744 * call.c (make_base_init_ok): Use DECL_HAS_VTT_PARM_P. gcc/testsuite/ChangeLog: PR c++/98744 * g++.dg/init/elide7.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/testsuite/g++.dg/init/elide7.C9
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index b6e9f12..a2c5ef7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8470,7 +8470,7 @@ make_base_init_ok (tree exp)
return true;
gcc_assert (DECL_COMPLETE_CONSTRUCTOR_P (fn));
fn = base_ctor_for (fn);
- if (!fn || DECL_HAS_IN_CHARGE_PARM_P (fn))
+ if (!fn || DECL_HAS_VTT_PARM_P (fn))
/* The base constructor has more parameters, so we can't just change the
call target. It would be possible to splice in the appropriate
arguments, but probably not worth the complexity. */
diff --git a/gcc/testsuite/g++.dg/init/elide7.C b/gcc/testsuite/g++.dg/init/elide7.C
new file mode 100644
index 0000000..d4bacaf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/elide7.C
@@ -0,0 +1,9 @@
+// PR c++/98744
+// { dg-additional-options "-O2 -fno-inline -Wmaybe-uninitialized" }
+
+struct A {};
+struct B : virtual A {};
+struct C : B {
+ C() : B(B()) {}
+};
+int main() { C c; return 0; }