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

            Bug ID: 79531
           Summary: bad location when trying to define undeclared method
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tromey at gcc dot gnu.org
  Target Milestone: ---

Consider this source:

=======
struct base {
  virtual void m() = 0;
};

struct derived : public base {
  virtual void m() override;
  virtual void method2() override;
};

void derived::n ()
{
}
=======

This has two errors -- one that "method2" is declared override but doesn't
in fact override; and two that "n" is defined but not declared in the class.

Compiling with g++ gives:

bapiya. g++ -c x.cc
g++ -c x.cc
x.cc:7:16: error: ‘virtual void derived::method2()’ marked ‘override’, but does
not override
   virtual void method2() override;
                ^~~~~~~
x.cc:10:18: error: no ‘void derived::n()’ member function declared in class
‘derived’
 void derived::n ()
                  ^


For "method2" the location is where I'd expect.
However, for "n" the location comes after the close parens.
I think the "n" case should use the location of the identifier "n",
like the "method2" case does.


I'm using the system gcc on Fedora 25:

bapiya. gcc --version
gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)

Reply via email to