* class.c (one_inheriting_sig): Don't inherit base copy ctors.
From-SVN: r193623
This commit is contained in:
parent
61d1b82145
commit
e252e96aae
@ -1,5 +1,7 @@
|
||||
2012-11-19 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* class.c (one_inheriting_sig): Don't inherit base copy ctors.
|
||||
|
||||
PR c++/55262
|
||||
* method.c (implicitly_declare_fn): Set DECL_PARM_INDEX on
|
||||
the parms of an inheriting ctor.
|
||||
|
@ -2886,15 +2886,19 @@ static void
|
||||
one_inheriting_sig (tree t, tree ctor, tree *parms, int nparms)
|
||||
{
|
||||
/* We don't declare an inheriting ctor that would be a default,
|
||||
copy or move ctor. */
|
||||
if (nparms == 0
|
||||
|| (nparms == 1
|
||||
&& TREE_CODE (parms[0]) == REFERENCE_TYPE
|
||||
&& TYPE_MAIN_VARIANT (TREE_TYPE (parms[0])) == t))
|
||||
copy or move ctor for derived or base. */
|
||||
if (nparms == 0)
|
||||
return;
|
||||
int i;
|
||||
if (nparms == 1
|
||||
&& TREE_CODE (parms[0]) == REFERENCE_TYPE)
|
||||
{
|
||||
tree parm = TYPE_MAIN_VARIANT (TREE_TYPE (parms[0]));
|
||||
if (parm == t || parm == DECL_CONTEXT (ctor))
|
||||
return;
|
||||
}
|
||||
|
||||
tree parmlist = void_list_node;
|
||||
for (i = nparms - 1; i >= 0; i--)
|
||||
for (int i = nparms - 1; i >= 0; i--)
|
||||
parmlist = tree_cons (NULL_TREE, parms[i], parmlist);
|
||||
tree fn = implicitly_declare_fn (sfk_inheriting_constructor,
|
||||
t, false, ctor, parmlist);
|
||||
|
15
gcc/testsuite/g++.dg/cpp0x/inh-ctor15.C
Normal file
15
gcc/testsuite/g++.dg/cpp0x/inh-ctor15.C
Normal file
@ -0,0 +1,15 @@
|
||||
// Discussions on the core reflector indicate that not inheriting base copy
|
||||
// constructors was a deliberate choice.
|
||||
|
||||
// { dg-options -std=c++11 }
|
||||
|
||||
struct A { A(int); };
|
||||
struct B: public A
|
||||
{
|
||||
using A::A;
|
||||
};
|
||||
|
||||
A a (42);
|
||||
|
||||
B b1 (24); // inherited
|
||||
B b2 (a); // not inherited { dg-error "no match" }
|
Loading…
Reference in New Issue
Block a user