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

            Bug ID: 100919
           Summary: multiple -Wdeprecated-declarations on a call to a
                    deprecated member function pointer
           Product: gcc
           Version: 11.1.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 test case below shows that G++ issues three identical warnings for a single
call to function through a member pointer (both with [[deprecated]] or
__attribute__ ((deprecated))).  It should issue one one warning, same as for
direct calls.

$ cat t.C && gcc  -S -Wall t.C
struct A
{
  [[deprecated]] int f ();
  [[deprecated]] int (*pf) (); 
};

void f (A *p)
{
  p->f ();   // one warning (good)
}

void g (A *p)
{
  p->pf ();  // three warnings (bug)
}


t.C: In function ‘void f(A*)’:
t.C:9:8: warning: ‘int A::f()’ is deprecated [-Wdeprecated-declarations]
    9 |   p->f ();   // one warning (good)
      |   ~~~~~^~
t.C:3:22: note: declared here
    3 |   [[deprecated]] int f ();
      |                      ^
t.C: In function ‘void g(A*)’:
t.C:14:6: warning: ‘A::pf’ is deprecated [-Wdeprecated-declarations]
   14 |   p->pf ();  // three warnings (bug)
      |      ^~
t.C:4:24: note: declared here
    4 |   [[deprecated]] int (*pf) ();
      |                        ^~
t.C:14:6: warning: ‘A::pf’ is deprecated [-Wdeprecated-declarations]
   14 |   p->pf ();  // three warnings (bug)
      |      ^~
t.C:4:24: note: declared here
    4 |   [[deprecated]] int (*pf) ();
      |                        ^~
t.C:14:6: warning: ‘A::pf’ is deprecated [-Wdeprecated-declarations]
   14 |   p->pf ();  // three warnings (bug)
      |      ^~
t.C:4:24: note: declared here
    4 |   [[deprecated]] int (*pf) ();
      |                        ^~

Reply via email to