Skip to content

Commit

Permalink
PR c++/79503 - inherited ctor taking base class
Browse files Browse the repository at this point in the history
	* call.c (add_function_candidate): Also check that
	DECL_INHERITED_CTOR_BASE is reference-related to the parameter type.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245586 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
jason committed Feb 20, 2017
1 parent ad2c271 commit 67378ae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2017-02-19 Jason Merrill <jason@redhat.com>

PR c++/79503 - inherited ctor taking base class
* call.c (add_function_candidate): Also check that
DECL_INHERITED_CTOR_BASE is reference-related to the parameter type.

2017-02-19 Paolo Carlini <paolo.carlini@oracle.com>

PR c++/79380
Expand Down
4 changes: 3 additions & 1 deletion gcc/cp/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,9 @@ add_function_candidate (struct z_candidate **candidates,
{
tree ptype = non_reference (TREE_VALUE (parmlist));
tree dtype = DECL_CONTEXT (fn);
if (reference_related_p (ptype, dtype))
tree btype = DECL_INHERITED_CTOR_BASE (fn);
if (reference_related_p (ptype, dtype)
&& reference_related_p (btype, ptype))
{
viable = false;
reason = inherited_ctor_rejection ();
Expand Down
21 changes: 21 additions & 0 deletions gcc/testsuite/g++.dg/cpp0x/inh-ctor26.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// PR c++/79503
// { dg-do compile { target c++11 } }

struct payload {};

struct base: private payload {
base(payload) {}
};

struct derived: base {
using base::base;
};

int main()
{
payload data;
// error: no matching function for call to 'derived::derived(payload&)'
// note: candidate: base::base(payload)
// note: an inherited constructor is not a candidate for initialization from an expression of the same or derived type
derived demo(data);
}

0 comments on commit 67378ae

Please sign in to comment.