As I read the documentation for the attribute, warnings should be issued when a
deprecated entity is used and not when that deprecation is declared.

Thus, as I read it, the following lines should not result in a warning until
the entities they declare are used:
(Lines marked as bogus).

This is not the current behavior of either C or C++   
(and they differ in degree of difference from the expectation identified above)

C:

typedef int INT1 __attribute__((deprecated));
typedef INT1 INT2 __attribute__((deprecated)); /* { dg-bogus "'INT1' is
deprecated" "" } */

INT1 foo (void) __attribute__((deprecated));  /* { dg-bogus "'INT1' is
deprecated" "" } */
int bar (INT1 x) __attribute__((deprecated)); /* { dg-bogus "'INT1' is
deprecated" "" } */
INT1 baz (INT1 y) __attribute__((deprecated)); /* { dg-bogus "'INT1' is
deprecated" "" } */

struct s1_rec {
  int t1;
  INT1 t2 __attribute__((deprecated)) ; /* { dg-bogus "'INT1' is deprecated" ""
} */
} ;

C++:

typedef int INT1 __attribute__((deprecated));
typedef INT1 INT2 __attribute__((deprecated)); /* { dg-bogus "'INT1' is
deprecated" "" } */

INT1 foo (void) __attribute__((deprecated));  /* { dg-bogus "'INT1' is
deprecated" "" } */
int bar (INT1 x) __attribute__((deprecated)); /* { dg-bogus "'INT1' is
deprecated" "" } */
INT1 baz (INT1 y) __attribute__((deprecated)); /* { dg-bogus "'INT1' is
deprecated" "" } */

struct s1_rec {
  int t1;
  INT1 t2 __attribute__((deprecated)) ; /* { dg-bogus "'INT1' is deprecated" ""
} */
} ;

class T {
  public:
    void member1(int) __attribute__ ((deprecated));
    void member2(INT1) __attribute__ ((__deprecated__)); /* { dg-bogus "'INT1'
is deprecated" "" } */
    int member3(T *);
} ;


-- 
           Summary: C/C++ __attribute__((deprecated)) does not appear to
                    wrap declarations as implied from the doc.
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: iains at gcc dot gnu dot org
GCC target triplet: *-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43778

Reply via email to