Let's use warning_sentinel to suppress -Wuseless-cast for this conversion. Tested x86_64-pc-linux-gnu, applying to trunk and 7.
commit 74a5be8e0ca159667f4b3e87a0b329345afaf0fa Author: Jason Merrill <ja...@redhat.com> Date: Fri Jun 16 23:06:17 2017 -0400
PR c++/70844 - -Wuseless-cast and inheriting constructor. * method.c (forward_parm): Suppress warn_useless_cast. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 9541fcb..fe4b2af 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -486,6 +486,7 @@ forward_parm (tree parm) type = PACK_EXPANSION_PATTERN (type); if (TREE_CODE (type) != REFERENCE_TYPE) type = cp_build_reference_type (type, /*rval=*/true); + warning_sentinel w (warn_useless_cast); exp = build_static_cast (type, exp, tf_warning_or_error); if (DECL_PACK_P (parm)) exp = make_pack_expansion (exp); diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor27.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor27.C new file mode 100644 index 0000000..ef2ada1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor27.C @@ -0,0 +1,13 @@ +// PR c++/70844 +// { dg-options -Wuseless-cast } +// { dg-do compile { target c++11 } } + +struct base { + base (int const &); +}; + +struct derived : public base { + using base::base; +}; + +derived d(0);