[Bug c/23722] New: bad error recovery with if blocks and else

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sun Sep 4 14:10:00 GMT 2005


An example:

int f()
{
  if (1)
  {
   return 1;
  else
  {
  }
}

the else should cause us to close the } block and we should only have one error message.  Right now we 
have two:
t.c: In function ‘f’:
t.c:6: error: expected expression before ‘else’
t.c:9: error: expected declaration or statement at end of input

The reason why I only want one error message is that we only have to fix this one place.
----
If we do:
int f()
{
  if (1)
  {
   return 1;
  else
  {
   }
  }
}

We get only one which is not fully correct as the block after the else was closed twice.

-- 
           Summary: bad error recovery with if blocks and else
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23722



More information about the Gcc-bugs mailing list