call.c (add_function_candidate): Exclude inherited copy/move ctors.
* call.c (add_function_candidate): Exclude inherited copy/move ctors. From-SVN: r243138
This commit is contained in:
parent
c1ff51dc9f
commit
03e88100e1
4 changed files with 42 additions and 14 deletions
|
@ -1,3 +1,8 @@
|
|||
2016-12-01 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* call.c (add_function_candidate): Exclude inherited copy/move
|
||||
ctors.
|
||||
|
||||
2016-11-29 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
PR c++/77922
|
||||
|
|
|
@ -2042,6 +2042,25 @@ add_function_candidate (struct z_candidate **candidates,
|
|||
reason = arity_rejection (first_arg, i + remaining, len);
|
||||
}
|
||||
|
||||
/* A constructor that is a direct member of a class C and has a first
|
||||
parameter of type "reference to cv C" (including such a constructor
|
||||
instantiated from a template) is excluded from the set of candidate
|
||||
functions when used to construct an object of type derived from C (12.6.3
|
||||
[class.inhctor.init]) with an argument list containing a single
|
||||
argument. */
|
||||
if (viable && len == 1 && parmlist && DECL_CONSTRUCTOR_P (fn)
|
||||
&& flag_new_inheriting_ctors
|
||||
&& DECL_INHERITED_CTOR (fn))
|
||||
{
|
||||
tree ptype = non_reference (TREE_VALUE (parmlist));
|
||||
tree ctype = DECL_INHERITED_CTOR_BASE (fn);
|
||||
if (same_type_ignoring_top_level_qualifiers_p (ptype, ctype))
|
||||
{
|
||||
viable = false;
|
||||
reason = inherited_ctor_rejection ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Second, for a function to be viable, its constraints must be
|
||||
satisfied. */
|
||||
if (flag_concepts && viable
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
// P0136 caused us to start inheriting base copy constructors.
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options -fnew-inheriting-ctors }
|
||||
|
||||
struct A { A(int); };
|
||||
struct B: public A
|
||||
{
|
||||
using A::A;
|
||||
};
|
||||
|
||||
A a (42);
|
||||
|
||||
B b1 (24); // inherited
|
||||
B b2 (a); // also inherited now
|
18
gcc/testsuite/g++.dg/cpp1z/inh-ctor36.C
Normal file
18
gcc/testsuite/g++.dg/cpp1z/inh-ctor36.C
Normal file
|
@ -0,0 +1,18 @@
|
|||
// { dg-do link { target c++11 } }
|
||||
|
||||
struct X { X(X &&); };
|
||||
struct A {
|
||||
A() {}
|
||||
A(const A&); // #1
|
||||
A(A &&) = default; // #2, defined as deleted (12.8 [class.copy])
|
||||
template<typename T> A(T &&); // #3
|
||||
union { X x; };
|
||||
};
|
||||
struct B : A {
|
||||
using A::A;
|
||||
B(...) {}
|
||||
};
|
||||
|
||||
int main() {
|
||||
B b = A(); // calls B::B(...): #1, #2, and #3 are excluded from candidate set
|
||||
}
|
Loading…
Add table
Reference in a new issue