Commit 310a7f96 by Jason Merrill Committed by Jason Merrill

call.c (add_function_candidate): Also exclude inherited ctors that take a type…

call.c (add_function_candidate): Also exclude inherited ctors that take a type reference-related to the derived...

	* call.c (add_function_candidate): Also exclude inherited ctors
	that take a type reference-related to the derived class.

From-SVN: r243178
parent 03fd1ef6
2016-12-01 Jason Merrill <jason@redhat.com> 2016-12-01 Jason Merrill <jason@redhat.com>
* call.c (add_function_candidate): Also exclude inherited ctors
that take a type reference-related to the derived class.
* call.c (add_function_candidate): Exclude inherited copy/move * call.c (add_function_candidate): Exclude inherited copy/move
ctors. ctors.
......
...@@ -2042,19 +2042,18 @@ add_function_candidate (struct z_candidate **candidates, ...@@ -2042,19 +2042,18 @@ add_function_candidate (struct z_candidate **candidates,
reason = arity_rejection (first_arg, i + remaining, len); reason = arity_rejection (first_arg, i + remaining, len);
} }
/* A constructor that is a direct member of a class C and has a first /* An inherited constructor (12.6.3 [class.inhctor.init]) that has a first
parameter of type "reference to cv C" (including such a constructor parameter of type "reference to cv C" (including such a constructor
instantiated from a template) is excluded from the set of candidate 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 functions when used to construct an object of type D with an argument list
[class.inhctor.init]) with an argument list containing a single containing a single argument if C is reference-related to D. */
argument. */
if (viable && len == 1 && parmlist && DECL_CONSTRUCTOR_P (fn) if (viable && len == 1 && parmlist && DECL_CONSTRUCTOR_P (fn)
&& flag_new_inheriting_ctors && flag_new_inheriting_ctors
&& DECL_INHERITED_CTOR (fn)) && DECL_INHERITED_CTOR (fn))
{ {
tree ptype = non_reference (TREE_VALUE (parmlist)); tree ptype = non_reference (TREE_VALUE (parmlist));
tree ctype = DECL_INHERITED_CTOR_BASE (fn); tree dtype = DECL_CONTEXT (fn);
if (same_type_ignoring_top_level_qualifiers_p (ptype, ctype)) if (reference_related_p (ptype, dtype))
{ {
viable = false; viable = false;
reason = inherited_ctor_rejection (); reason = inherited_ctor_rejection ();
...@@ -2161,18 +2160,6 @@ add_function_candidate (struct z_candidate **candidates, ...@@ -2161,18 +2160,6 @@ add_function_candidate (struct z_candidate **candidates,
} }
} }
/* Don't consider inherited constructors for initialization from an
expression of the same or derived type. */
/* FIXME extend to operator=. */
if (i == 0 && len == 1
&& DECL_INHERITED_CTOR (fn)
&& reference_related_p (ctype, argtype))
{
viable = 0;
reason = inherited_ctor_rejection ();
goto out;
}
/* Core issue 899: When [copy-]initializing a temporary to be bound /* Core issue 899: When [copy-]initializing a temporary to be bound
to the first parameter of a copy constructor (12.8) called with to the first parameter of a copy constructor (12.8) called with
a single argument in the context of direct-initialization, a single argument in the context of direct-initialization,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment