[Bug c++/68615] New: Unhelpful location when missing a semi-colon on a function declaration at the end of a header

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 30 11:34:00 GMT 2015


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

            Bug ID: 68615
           Summary: Unhelpful location when missing a semi-colon on a
                    function declaration at the end of a header
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

# 1 "foo.cc"
# 1 "foo.h" 1
int f()
# 2 "foo.cc" 2

int main()
{
  f();
}


This gives:

foo.cc:3:1: error: expected initializer before ‘int’
 int main()
 ^

We fixed the case where we're missing ; after a class definition so the error
location is the end of the class, but for this case we still give the location
as the start of main. Ideally it would be:

foo.h:1:7: error: expected ‘;’ after function declaration


Related to Bug 56084, but that is about error recovery following the missing ;
and this is just about the location.


More information about the Gcc-bugs mailing list