* C++ PATCH for c++/70844, wrong -Wuseless-cast with inheriting constructor
@ 2017-06-18 4:28 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-06-18 4:28 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 129 bytes --]
Let's use warning_sentinel to suppress -Wuseless-cast for this conversion.
Tested x86_64-pc-linux-gnu, applying to trunk and 7.
[-- Attachment #2: 70844.diff --]
[-- Type: text/plain, Size: 1182 bytes --]
commit 74a5be8e0ca159667f4b3e87a0b329345afaf0fa
Author: Jason Merrill <jason@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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-18 4:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-18 4:28 C++ PATCH for c++/70844, wrong -Wuseless-cast with inheriting constructor Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).