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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
For this reduced version (without the non-static function which is correctly
only getting one warning):

struct myclass{
    [[deprecated("deprecated the static")]]
    static void static_deprecate() { }

};

int main()
{
    myclass v;
    myclass::static_deprecate();
    v.static_deprecate();
}

GCC 7 gives three warnings:

90451.cc: In function 'int main()':
90451.cc:10:14: warning: 'static void myclass::static_deprecate()' is
deprecated: deprecated the static [-Wdeprecated-declarations]
     myclass::static_deprecate();
              ^~~~~~~~~~~~~~~~
90451.cc:3:17: note: declared here
     static void static_deprecate() { }
                 ^~~~~~~~~~~~~~~~
90451.cc:10:31: warning: 'static void myclass::static_deprecate()' is
deprecated: deprecated the static [-Wdeprecated-declarations]
     myclass::static_deprecate();
                               ^
90451.cc:3:17: note: declared here
     static void static_deprecate() { }
                 ^~~~~~~~~~~~~~~~
90451.cc:11:24: warning: 'static void myclass::static_deprecate()' is
deprecated: deprecated the static [-Wdeprecated-declarations]
     v.static_deprecate();
                        ^
90451.cc:3:17: note: declared here
     static void static_deprecate() { }
                 ^~~~~~~~~~~~~~~~


Notice the two different locations for the qualified call:

     myclass::static_deprecate();
              ^~~~~~~~~~~~~~~~
     myclass::static_deprecate();
                               ^

The v.static_deprecate() call correctly only gets one warning.

But then with GCC 8 after r259067 there are three warnings for the qualified
call, with these locations:

     myclass::static_deprecate();
              ^~~~~~~~~~~~~~~~
     myclass::static_deprecate();
                               ^
     myclass::static_deprecate();
                               ^

and two for the member access expression, both with the same location:

     v.static_deprecate();
                        ^
     v.static_deprecate();
                        ^

The regression due to r259067 is tracked by PR 67960.

Reply via email to