This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix cp_parser_direct_declarator (PR c++/29886)


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.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]