This is the mail archive of the
mailing list for the GCC project.
Re: [C++ PATCH] Fix cp_parser_direct_declarator (PR c++/29886)
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 24 Nov 2006 21:18:39 -0800
- Subject: Re: [C++ PATCH] Fix cp_parser_direct_declarator (PR c++/29886)
- References: <20061123162600.GN6570@devserv.devel.redhat.com>
Jakub Jelinek wrote:
> cp_parser_direct_declarator is used even in tentative parsing, but
> is unconditionally issuing error, which breaks the attached testcase.
Thanks for looking at this!
However, I think the logic in the parser for issuing the error is
correct. There is a check before the error message that says "if we're
in a function scope, allow the VLA". The problem here is that we think
we're in a class scope because we see "A::", and enter that scope,
because, correctly, we need to look up any names after that point in the
scope of "A".
There is a parser-oriented fix. Inside a condition (in the C++ grammar
sense), disallow qualified names as declarator-ids, in the parser. That
would cause a parse error at the point of the "A::" -- before the
incorrect error message. We would do this via a new parser boolean;
something like "parser->qualified_declarator_id_ok = false".
I like this better than your solution because it avoids the oddity of
creating an known-invalid declarator, and because detecting errors
earlier in processing has empirically turned out to be more robust. If
you don't want to try this, let me know, and I'll be happy to work on it.
(650) 331-3385 x713