+2018-12-06 Jason Merrill <jason@redhat.com>
+
+ PR c++/88136 - -Wdeprecated-copy false positives
+ * c.opt (Wdeprecated-copy-dtor): New.
+ (Wdeprecated-copy): Move to -Wextra.
+
2018-11-29 Martin Sebor <msebor@redhat.com>
PR c/88172
Warn if a deprecated compiler feature, class, method, or field is used.
Wdeprecated-copy
-C++ ObjC++ Var(warn_deprecated_copy) Warning LangEnabledBy(C++ ObjC++, Wall)
+C++ ObjC++ Var(warn_deprecated_copy) Warning LangEnabledBy(C++ ObjC++, Wextra)
+Mark implicitly-declared copy operations as deprecated if the class has a
+user-provided copy operation.
+
+Wdeprecated-copy-dtor
+C++ ObjC++ Var(warn_deprecated_copy, 2) Warning
Mark implicitly-declared copy operations as deprecated if the class has a
user-provided copy operation or destructor.
+2018-12-06 Jason Merrill <jason@redhat.com>
+
+ PR c++/88136 - -Wdeprecated-copy false positives
+ * class.c (classtype_has_depr_implicit_copy): Rename from
+ classtype_has_user_copy_or_dtor.
+ * method.c (lazily_declare_fn): Adjust.
+ * decl2.c (cp_warn_deprecated_use): Refer to -Wdeprecated-copy-dtor
+ if deprecation is due to a destructor.
+
2018-12-06 Marek Polacek <polacek@redhat.com>
PR c++/88373 - wrong parse error with ~.
operator, or destructor, returns that function. Otherwise, null. */
tree
-classtype_has_user_copy_or_dtor (tree t)
+classtype_has_depr_implicit_copy (tree t)
{
if (!CLASSTYPE_LAZY_COPY_CTOR (t))
for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
extern bool type_has_virtual_destructor (tree);
extern bool classtype_has_move_assign_or_move_ctor_p (tree, bool user_declared);
extern bool classtype_has_non_deleted_move_ctor (tree);
-extern tree classtype_has_user_copy_or_dtor (tree);
+extern tree classtype_has_depr_implicit_copy (tree);
extern bool type_build_ctor_call (tree);
extern bool type_build_dtor_call (tree);
extern void explain_non_literal_class (tree);
&& DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
&& copy_fn_p (decl))
{
- auto_diagnostic_group d;
- /* Don't warn about system library classes (c++/86342). */
- if (!DECL_IN_SYSTEM_HEADER (decl))
- warned = warning (OPT_Wdeprecated_copy,
- "implicitly-declared %qD is deprecated", decl);
- if (warned)
+ if (warn_deprecated_copy
+ /* Don't warn about system library classes (c++/86342). */
+ && (!DECL_IN_SYSTEM_HEADER (decl)
+ || global_dc->dc_warn_system_headers))
{
+ auto_diagnostic_group d;
tree ctx = DECL_CONTEXT (decl);
- tree other = classtype_has_user_copy_or_dtor (ctx);
- inform (DECL_SOURCE_LOCATION (other),
- "because %qT has user-provided %qD",
- ctx, other);
+ tree other = classtype_has_depr_implicit_copy (ctx);
+ int opt = (DECL_DESTRUCTOR_P (other)
+ ? OPT_Wdeprecated_copy_dtor
+ : OPT_Wdeprecated_copy);
+ warned = warning (opt, "implicitly-declared %qD is deprecated",
+ decl);
+ if (warned)
+ inform (DECL_SOURCE_LOCATION (other),
+ "because %qT has user-provided %qD",
+ ctx, other);
}
}
else
{
if (classtype_has_move_assign_or_move_ctor_p (type, true))
DECL_DELETED_FN (fn) = true;
- else if (classtype_has_user_copy_or_dtor (type))
+ else if (classtype_has_depr_implicit_copy (type))
/* The implicit definition of a copy constructor as defaulted is
deprecated if the class has a user-declared copy assignment operator
or a user-declared destructor. The implicit definition of a copy
-fvisibility-ms-compat @gol
-fext-numeric-literals @gol
-Wabi=@var{n} -Wabi-tag -Wconversion-null -Wctor-dtor-privacy @gol
--Wdelete-non-virtual-dtor -Wdeprecated-copy -Wliteral-suffix @gol
+-Wdelete-non-virtual-dtor -Wdeprecated-copy -Wdeprecated-copy-dtor @gol
+-Wliteral-suffix @gol
-Wmultiple-inheritance -Wno-init-list-lifetime @gol
-Wnamespaces -Wnarrowing @gol
-Wpessimizing-move -Wredundant-move @gol
@opindex Wno-deprecated-copy
Warn that the implicit declaration of a copy constructor or copy
assignment operator is deprecated if the class has a user-provided
-copy constructor, copy assignment operator, or destructor, in C++11
-and up. This warning is enabled by @option{-Wall}.
+copy constructor or copy assignment operator, in C++11 and up. This
+warning is enabled by @option{-Wextra}. With
+@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
+user-provided destructor.
@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
@opindex Winit-list-lifetime
@gccoptlist{-Wclobbered @gol
-Wcast-function-type @gol
+-Wdeprecated-copy @r{(C++ only)} @gol
-Wempty-body @gol
-Wignored-qualifiers @gol
-Wimplicit-fallthrough=3 @gol
of this International Standard, these implicit definitions could become
deleted (11.4). */
-// { dg-additional-options -Wdeprecated-copy }
+// { dg-additional-options -Wdeprecated-copy-dtor }
struct X
{