https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79586
Bug ID: 79586
Summary: missing -Wdeprecated depending on position of
attribute
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
GCC (in both C and C++ modes) is inconsistent in warning for uses of entities
declared with attribute deprecated. In the following program the first four of
all uses of the deprecated variables and types should be diagnosed. Instead,
only two of them are. Both Clang and Intel ICC diagnose all four of them as
expected.
$ cat u.C && gcc -O2 -S -Wall -Wextra -Wpedantic -Wunused -xc u.C
int* f0 (void)
{
int* p __attribute__ ((deprecated)) = 0;
return p; // warning, ok
}
int* f1 (void)
{
int* __attribute__ ((deprecated)) p = 0;
return p; // no warning, bug
}
int* f2 (void)
{
typedef int* P __attribute__ ((deprecated));
P p = 0; // warning, ok
return p;
}
int* f3 (void)
{
typedef int* __attribute__ ((deprecated)) P;
P p = 0; // no warning, bug
return p;
}
u.C: In function ‘f0’:
u.C:5:3: warning: ‘p’ is deprecated [-Wdeprecated-declarations]
return p; // warning, ok
^~~~~~
u.C:3:8: note: declared here
int* p __attribute__ ((deprecated)) = 0;
^
u.C: In function ‘f2’:
u.C:18:3: warning: ‘P’ is deprecated [-Wdeprecated-declarations]
P p = 0; // warning, ok
^