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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Jonny Grant from comment #3)
> A different example where GCC does a good job of indicating the line number
> of a missing comma problem.
> 
> 
> https://godbolt.org/z/asGhE3W17
> 
> 
> <source>:6:5: error: expected '}' before '{' token
>     6 |     {"G", "H"},
>       |     ^
> <source>:2:1: note: to match this '{'
>     2 | {
>       | ^
> <source>:6:5: error: expected ',' or ';' before '{' token
>     6 |     {"G", "H"},
>       |     ^

This is easy because the parser has to insert a comma here to correct the
syntax.  But for a missing } it can be added at one of multiple places to make
the syntax correct.

The parser always keeps progressing unless it's sure there is a syntax error. 
Note that 

static const char * list[][2] =
{
    {"A", "B"},
    {"C", "D"},
    {"E", "F",
    {"G", "H"},
    {"I", "J"}
}};

is NOT a syntax error.  It's a semantic error (violating a constraint) but the
parser does not know about semantics (i.e. the parser does not know what "[2]"
means at all).  So the parser cannot be sure about the syntax error until the
last line.

Mixing the semantic analysis into the parser is not acceptable because it's not
how a compiler is implemented.

Make the parser try different locations and pass all possible syntax tree to
the further passes is at least quadratic behavior and not acceptable.

I'll say this WONTFIX.  If someone knows how to do this in a rational way
please reopen.

Reply via email to