The documentation for Parser::ParseFunctionDeclarator (hereafter referred to as PFD) has this note near the end:
For C++, after the parameter-list, it also parses "cv-qualifier-
seq[opt]", C++0x "ref-qualifier[opt]" and "exception-
specification[opt]".
I would like to use this function when parsing lambda expressions, but the extra parts it parses at the end are simultaneously too much (cv-qualifier-seq, ref-qualifier) and not enough (attribute-specifier, 'mutable') for lambdas.
I could try to call PFD anyway, then check if it parsed anything extra that it shouldn't have. I believe this is existing convention, e.g., to diagnose const-qualified non-member functions.
However, PFD calls Declarator::AddTypeInfo, which takes a DeclaratorChunk that, for function declarators, requires information about the parameters, qualifiers, exceptions, and return type all at once. Here is the documentation for DeclaratorChunk:
One instance of this struct is used for each type in a declarator
that is parsed.
This suggests to me that I cannot, after calling PFD, call AddTypeInfo to add the lambda-declarator parts that PFD missed. Thus, I see two options to address the situation:
1. Try to extend PFD to parse a lambda-declarator. Existing clients will need to add checks for the parts that don't belong in regular function declarators.
2. Factor code out of PFD into several component functions. Old clients can still use PFD, and I can use just the pieces I need. This is the option I personally favor.
Any thoughts?
- John