public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105702] New: Add fix-it for missing nested-name-specifier on out-of-class assignment operator
@ 2022-05-23 10:49 redi at gcc dot gnu.org
  2022-05-23 11:02 ` [Bug c++/105702] " redi at gcc dot gnu.org
  2023-05-19  4:48 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-23 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105702
           Summary: Add fix-it for missing nested-name-specifier on
                    out-of-class assignment operator
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

struct A {
  A& operator=(const A&);
};

A& operator=(const A&) { return *this; }


ool.C:5:4: error: ‘A& operator=(const A&)’ must be a non-static member function
    5 | A& operator=(const A&) { return *this; }
      |    ^~~~~~~~


The error is good, but it would be even better to suggest that the
qualification is missing:

    5 | A& operator=(const A&) { }
      |    ^
      |    A::

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/105702] Add fix-it for missing nested-name-specifier on out-of-class assignment operator
  2022-05-23 10:49 [Bug c++/105702] New: Add fix-it for missing nested-name-specifier on out-of-class assignment operator redi at gcc dot gnu.org
@ 2022-05-23 11:02 ` redi at gcc dot gnu.org
  2023-05-19  4:48 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-23 11:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Although it's possible this could be trying to define B::operator= or some
other member function, we should assume from the return type and parameter type
that it's A::operator=, which was declared and has not been defined yet.

If we want to avoid bad fix-its, we could limit it to cases where all those
clues are present: an invalid non-member operator= is defined where the return
type is X& and the parameter type is either const X& or X&&, and the body of X
declares (but does not define) an assignment op with exactly that signature.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/105702] Add fix-it for missing nested-name-specifier on out-of-class assignment operator
  2022-05-23 10:49 [Bug c++/105702] New: Add fix-it for missing nested-name-specifier on out-of-class assignment operator redi at gcc dot gnu.org
  2022-05-23 11:02 ` [Bug c++/105702] " redi at gcc dot gnu.org
@ 2023-05-19  4:48 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-19  4:48 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-05-19

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-19  4:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 10:49 [Bug c++/105702] New: Add fix-it for missing nested-name-specifier on out-of-class assignment operator redi at gcc dot gnu.org
2022-05-23 11:02 ` [Bug c++/105702] " redi at gcc dot gnu.org
2023-05-19  4:48 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).