* class.c (one_inheriting_sig): Don't inherit base copy ctors.

From-SVN: r193623
This commit is contained in:
Jason Merrill 2012-11-19 09:05:59 -05:00 committed by Jason Merrill
parent 61d1b82145
commit e252e96aae
3 changed files with 28 additions and 7 deletions

View File

@ -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.

View File

@ -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);

View 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" }