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

            Bug ID: 84887
           Summary: missing semicolon: further improvements
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: diagnostic, error-recovery
          Severity: normal
          Priority: P3
         Component: c
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Consider:

int test(void)
{
  return 42
}

Prior to gcc 8 we emitted:

t.c: In function ‘test’:
t.c:4:1: error: expected ‘;’ before ‘}’ token
 }
 ^

As of gcc 8 we now emit the error at the correct location:

t.c: In function ‘test’:
t.c:3:12: error: expected ‘;’ before ‘}’ token
   return 42
            ^
            ;
 }
 ~

(this was PR 65137 and others)

However, as suggested e.g. by oridb on Reddit, it would be more readable to
talk about the previous logical unit, and emit:

t.c: In function ‘test’:
t.c:3:12: error: expected ‘;’ after ‘42’ token
   return 42
            ^
            ;

or somesuch: e.g. should we highlight the preceding token as a secondary range,
which would give:

t.c: In function ‘test’:
t.c:3:12: error: expected ‘;’ after ‘42’ token
   return 42
          ~~^
            ;

(I'm not sure either way)

Reply via email to