https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79078
--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #8)
> One thing we should do is to
>
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -12643,7 +12643,7 @@ grokparms (tree parmlist, tree *parms)
> if (deprecated_state != DEPRECATED_SUPPRESS)
> {
> tree deptype = type_is_deprecated (type);
> - if (deptype)
> + if (deptype && !TYPE_BEING_DEFINED (deptype))
> warn_deprecated_use (deptype, NULL_TREE);
> }
>
>
> i.e. don't warn if the deprecated type is being defined.
That looks sensible, but only helps for uses of the type. It doesn't help this
case where a function is deprecated (this is based on a real change I want to
make to libstdc++):
struct string
{
#if __cplusplus == 201703L
[[deprecated("use shrink_to_fit() instead")]]
#elif __cplusplus > 201703L
private:
#endif
void reserve()
{ }
public:
void shrink_to_fit() { reserve(); }
};
int main()
{
string s;
s.shrink_to_fit();
}
When compiled as C++17 this issues a deprecated warning for the call from
shrink_to_fit(). The user of the class never calls the deprecated function
though. Calling it from another member of the class should not warn.
Marek, do you have a suggestion for how to suppress this one?
It would be very helpful to get a quick fix for this part, even if Martin's
more ambitious plan in comment 14 isn't going to be ready in the short term.