aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-12-02 08:58:32 -0500
committerJason Merrill <jason@gcc.gnu.org>2016-12-02 08:58:32 -0500
commit310a7f96996f46f1565376f092e08daa1d44d1e7 (patch)
tree640a45ccc5f0c33858a9452d87285932880ae033
parent03fd1ef632f41caaaa38a80712ed7eda3f97fdff (diff)
downloadgcc-310a7f96996f46f1565376f092e08daa1d44d1e7.zip
gcc-310a7f96996f46f1565376f092e08daa1d44d1e7.tar.gz
gcc-310a7f96996f46f1565376f092e08daa1d44d1e7.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/call.c23
2 files changed, 8 insertions, 18 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b407d17..4977ff2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
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
ctors.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 561cc83..b7aa97c 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2042,19 +2042,18 @@ 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
+ /* An inherited constructor (12.6.3 [class.inhctor.init]) that 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. */
+ functions when used to construct an object of type D with an argument list
+ containing a single argument if C is reference-related to D. */
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))
+ tree dtype = DECL_CONTEXT (fn);
+ if (reference_related_p (ptype, dtype))
{
viable = false;
reason = inherited_ctor_rejection ();
@@ -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
to the first parameter of a copy constructor (12.8) called with
a single argument in the context of direct-initialization,