[Bug c++/61754] [C++1y] [[deprecated]] attribute warns annoyingly compared to __attribute__((deprecated))
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 21 15:35:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61754
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
I find the [[deprecated]] behavior for the test cases here reasonable and
useful: the struct type is declared deprecated and so its subsequent uses are
diagnosed.
What I think is missing is a way for the author of a deprecated type (but not
its users) to define objects of the type without triggering the warning,
analogous to how it can be done for functions. I would expect the following to
do it but it doesn't:
$ cat u.C && gcc -S -Wall -Wextra -Wpedantic u.C
struct S { };
S a [[deprecated]]; // expect no warning here
struct [[deprecated]] S; // nor here
S b; // expect -Wdeprecated-declarations here
// Expected behavior:
int f () { return 0; }
[[deprecated]] int i = f (); // no warning
[[deprecated]] int f (); // no warning
int j = f (); // -Wdeprecated-declarations
u.C:5:23: warning: type attributes ignored after type is already defined
[-Wattributes]
struct [[deprecated]] S; // nor here
^
u.C:18:12: warning: ‘int f()’ is deprecated [-Wdeprecated-declarations]
int j = f (); // -Wdeprecated-declarations
^
u.C:12:5: note: declared here
int f () { return 0; }
^
Daniel, does this make sense to you?
More information about the Gcc-bugs
mailing list