This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/77711] Add fix-it hints for missing parentheses in member function call


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-09-23
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If the function is overloaded we get a different, equally unhelpful error:

struct A {
  int foo();
  int foo() const;
};

void bar(int);

int main()
{
  A a;
  bar( a.foo );
}

foo.cc: In function ‘int main()’:
foo.cc:11:14: error: cannot resolve overloaded function ‘foo’ based on
conversion to type ‘int’
   bar( a.foo );
              ^

It's irrelevant that we can't resolve which overload to use, once name lookup
finds that 'foo' is a function then a.foo is not a valid expression under any
circumstances.

This should also suggest a.foo()

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]