SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_register,
cxx_dialect >= cxx17);
+ /* Explicit -Wdeprecated turns on warnings from later standards. */
+ auto deprecated_in = [&](enum cxx_dialect d)
+ {
+ if (OPTION_SET_P (warn_deprecated)) return !!warn_deprecated;
+ return (warn_deprecated && cxx_dialect >= d);
+ };
+
/* -Wcomma-subscript is enabled by default in C++20. */
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
warn_comma_subscript,
cxx_dialect >= cxx23
- || (cxx_dialect == cxx20 && warn_deprecated));
+ || deprecated_in (cxx20));
/* -Wvolatile is enabled by default in C++20. */
SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_volatile,
- cxx_dialect >= cxx20 && warn_deprecated);
+ deprecated_in (cxx20));
/* -Wdeprecated-enum-enum-conversion is enabled by default in C++20. */
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
warn_deprecated_enum_enum_conv,
- cxx_dialect >= cxx20 && warn_deprecated);
+ deprecated_in (cxx20));
/* -Wdeprecated-enum-float-conversion is enabled by default in C++20. */
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
warn_deprecated_enum_float_conv,
- cxx_dialect >= cxx20 && warn_deprecated);
+ deprecated_in (cxx20));
/* -Wdeprecated-literal-operator is enabled by default in C++23. */
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
warn_deprecated_literal_operator,
- cxx_dialect >= cxx23 && warn_deprecated);
+ deprecated_in (cxx23));
/* -Wtemplate-id-cdtor is enabled by default in C++20. */
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
in C++20 with a pedantic warning that can be disabled with
@option{-Wno-comma-subscript}.
-Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
-and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
+Enabled by default with @option{-std=c++20} unless
+@option{-Wno-deprecated}, and after @option{-std=c++23} regardless of
+@option{-Wno-deprecated}. Before @option{-std=c++20}, enabled with
+explicit @option{-Wdeprecated}.
This warning is upgraded to an error by @option{-pedantic-errors} in
C++23 mode or later.
@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
-by @option{-Wenum-conversion}.
+by @option{-Wenum-conversion} or @option{-Wdeprecated}.
@opindex Wdeprecated-enum-float-conversion
@opindex Wno-deprecated-enum-float-conversion
@option{-Wdeprecated-enum-float-conversion} is enabled by default with
@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
-by @option{-Wenum-conversion}.
+by @option{-Wenum-conversion} or @option{-Wdeprecated}.
@opindex Wdeprecated-literal-operator
@opindex Wno-deprecated-literal-operator
@item -Wdeprecated-literal-operator @r{(C++ and Objective-C++ only)}
Warn that the declaration of a user-defined literal operator with a
space before the suffix is deprecated. This warning is enabled by
-default in C++23.
+default in C++23, or with explicit @option{-Wdeprecated}.
@smallexample
string operator "" _i18n(const char*, std::size_t); // deprecated
@code{volatile}-qualified parameter type, and structured bindings of a
@code{volatile}-qualified type. This usage was deprecated in C++20.
-Enabled by default with @option{-std=c++20}.
+Enabled by default with @option{-std=c++20}. Before
+@option{-std=c++20}, enabled with explicit @option{-Wdeprecated}.
@opindex Wzero-as-null-pointer-constant
@opindex Wno-zero-as-null-pointer-constant
@item -Wno-deprecated
Do not warn about usage of deprecated features. @xref{Deprecated Features}.
+In C++, explicitly specifying @option{-Wdeprecated} also enables
+warnings about some features that are deprecated in later language
+standards, specifically @option{-Wcomma-subscript},
+@option{-Wvolatile}, @option{-Wdeprecated-enum-float-conversion},
+@option{-Wdeprecated-enum-enum-conversion}, and
+@option{-Wdeprecated-literal-operator}.
+
@opindex Wno-deprecated-declarations
@opindex Wdeprecated-declarations
@item -Wno-deprecated-declarations