From: Jason Merrill Date: Mon, 21 May 2018 03:53:00 +0000 (-0400) Subject: PR libstdc++/85843 - warning in logic_error copy constructor. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f3f7cefecc833b4ab652215ceb8b408c21dca225;p=gcc.git PR libstdc++/85843 - warning in logic_error copy constructor. * class.c (type_has_user_nondefault_constructor): Check for a user-provided ctor, not user-declared. From-SVN: r260432 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 92039fa8e9a..29edd5f247b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-05-20 Jason Merrill + + PR libstdc++/85843 - warning in logic_error copy constructor. + * class.c (type_has_user_nondefault_constructor): Check for a + user-provided ctor, not user-declared. + 2018-05-19 Jason Merrill * pt.c (tsubst_pack_expansion): Sorry rather than abort diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 4960b4b5593..a9a0fa92727 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4884,7 +4884,7 @@ default_ctor_p (tree fn) && sufficient_parms_p (FUNCTION_FIRST_USER_PARMTYPE (fn))); } -/* Returns true iff class T has a user-defined constructor that can be called +/* Returns true iff class T has a user-provided constructor that can be called with more than zero arguments. */ bool @@ -4896,7 +4896,7 @@ type_has_user_nondefault_constructor (tree t) for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { tree fn = *iter; - if (!DECL_ARTIFICIAL (fn) + if (user_provided_p (fn) && (TREE_CODE (fn) == TEMPLATE_DECL || (skip_artificial_parms_for (fn, DECL_ARGUMENTS (fn)) != NULL_TREE))) diff --git a/gcc/testsuite/g++.dg/warn/Wextra-4.C b/gcc/testsuite/g++.dg/warn/Wextra-4.C new file mode 100644 index 00000000000..5c33c271154 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wextra-4.C @@ -0,0 +1,15 @@ +// PR libstdc++/85843 +// { dg-do compile { target c++11 } } +// { dg-additional-options -Wextra } + +struct A +{ + A(); + A(const A&) = default; +}; + +struct B : A +{ + B(): A() { } + B(const B&) { } +};