https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96619

            Bug ID: 96619
           Summary: attribute deprecated immediately before a parameter
                    has no effect
           Product: gcc
           Version: 11.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: ---

The following test case shows that while attribute unused suppresses a warning
about unused pointer parameter regardless of its placement, attribute
deprecated is not respected when it immediately precedes the parameter name.

The C++ front end behaves as expected, as do Clang and ICC.

$ cat t.c && gcc -S -Wall t.c
void f1 (__attribute__ ((unused)) int *p) { }
void g1 (int __attribute__ ((unused)) *p) { }
void h1 (int *__attribute__ ((unused)) p) { }
void i1 (int *p __attribute__ ((unused))) { }

void* f2 (__attribute__ ((deprecated)) int *p) { return p; }
void* g2 (int __attribute__ ((deprecated)) *p) { return p; }
void* h2 (int *__attribute__ ((deprecated)) p) { return p; }   // missing
warning
void* i2 (int *p __attribute__ ((deprecated))) { return p; }

t.c: In function ‘f2’:
t.c:6:1: warning: ‘p’ is deprecated [-Wdeprecated-declarations]
    6 | void* f2 (__attribute__ ((deprecated)) int *p) { return p; }
      | ^~~~
t.c:6:45: note: declared here
    6 | void* f2 (__attribute__ ((deprecated)) int *p) { return p; }
      |                                        ~~~~~^
t.c: In function ‘g2’:
t.c:7:1: warning: ‘p’ is deprecated [-Wdeprecated-declarations]
    7 | void* g2 (int __attribute__ ((deprecated)) *p) { return p; }
      | ^~~~
t.c:7:45: note: declared here
    7 | void* g2 (int __attribute__ ((deprecated)) *p) { return p; }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
t.c: In function ‘i2’:
t.c:9:1: warning: ‘p’ is deprecated [-Wdeprecated-declarations]
    9 | void* i2 (int *p __attribute__ ((deprecated))) { return p; }
      | ^~~~
t.c:9:16: note: declared here
    9 | void* i2 (int *p __attribute__ ((deprecated))) { return p; }
      |           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to