From d8af1a555746ae398d3328813546ed17d418b857 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 12 Feb 2013 15:47:15 -0500 Subject: [PATCH] re PR c++/56285 ([C++11] Arguments to an inheriting constructor are not forwarded properly) PR c++/56285 * method.c (add_one_base_init): Handle base constructor taking rvalue reference parm. From-SVN: r195990 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/method.c | 3 ++- gcc/testsuite/g++.dg/cpp0x/inh-ctor16.C | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/inh-ctor16.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d4d5cf..bc4e41c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-02-12 Jason Merrill + PR c++/56285 + * method.c (add_one_base_init): Handle base constructor + taking rvalue reference parm. + PR c++/56291 * semantics.c (sort_constexpr_mem_initializers): Handle vptr out of order. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index a1bab95..ff29b59 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -500,7 +500,8 @@ add_one_base_init (tree binfo, tree parm, bool move_p, tree inh, for (; parm; parm = DECL_CHAIN (parm)) { tree exp = convert_from_reference (parm); - if (TREE_CODE (TREE_TYPE (parm)) != REFERENCE_TYPE) + if (TREE_CODE (TREE_TYPE (parm)) != REFERENCE_TYPE + || TYPE_REF_IS_RVALUE (TREE_TYPE (parm))) exp = move (exp); *p = build_tree_list (NULL_TREE, exp); p = &TREE_CHAIN (*p); diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor16.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor16.C new file mode 100644 index 0000000..58e848b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor16.C @@ -0,0 +1,15 @@ +// PR c++/56285 +// { dg-options -std=c++11 } + +struct foo { + explicit foo(int&&) {} +}; + +struct bar: private foo { + using foo::foo; +}; + +int main() +{ + bar b { 42 }; +} -- 2.7.4