From 0bcd172dbf4f3d9168d4436e5f34730b8987762a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 21 Dec 2016 14:10:23 -0500 Subject: [PATCH] PR c++/78767 - ICE with inherited constructor default argument * method.c (strip_inheriting_ctors): Strip template as appropriate. From-SVN: r243864 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/method.c | 6 +++++- gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c4c51719374..1b14e1980c8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2016-12-21 Jason Merrill + PR c++/78767 - ICE with inherited constructor default argument + * method.c (strip_inheriting_ctors): Strip template as appropriate. + PR c++/78749 - friend in anonymous namespace * decl.c (wrapup_globals_for_namespace): Don't complain about friend pseudo-template instantiations. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 73d42b19d55..a5271a443cf 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -496,14 +496,18 @@ forward_parm (tree parm) constructor from a (possibly indirect) base class. */ tree -strip_inheriting_ctors (tree fn) +strip_inheriting_ctors (tree dfn) { gcc_assert (flag_new_inheriting_ctors); + tree fn = dfn; while (tree inh = DECL_INHERITED_CTOR (fn)) { inh = OVL_CURRENT (inh); fn = inh; } + if (TREE_CODE (fn) == TEMPLATE_DECL + && TREE_CODE (dfn) == FUNCTION_DECL) + fn = DECL_TEMPLATE_RESULT (fn); return fn; } diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C new file mode 100644 index 00000000000..7c1fae0cfc7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C @@ -0,0 +1,15 @@ +// PR c++/78767 +// { dg-do compile { target c++11 } } + +template struct A +{ + template + A(U, U = 42); +}; + +struct B: A +{ + using A::A; +}; + +B b(24);