PR c++/70844 - -Wuseless-cast and inheriting constructor.
authorJason Merrill <jason@redhat.com>
Sun, 18 Jun 2017 04:25:15 +0000 (00:25 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 18 Jun 2017 04:25:15 +0000 (00:25 -0400)
* method.c (forward_parm): Suppress warn_useless_cast.

From-SVN: r249344

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/testsuite/g++.dg/cpp0x/inh-ctor27.C [new file with mode: 0644]

index dba5e4d..d082574 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/70844 - -Wuseless-cast and inheriting constructor.
+       * method.c (forward_parm): Suppress warn_useless_cast.
+
 2017-06-16  Jason Merrill  <jason@redhat.com>
 
        PR c++/81045 - Wrong type-dependence with auto return type.
index 9541fcb..fe4b2af 100644 (file)
@@ -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 (file)
index 0000000..ef2ada1
--- /dev/null
@@ -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);