[cfe-dev] [PATCH]: Parsing for C++ classes

Eli Friedman eli.friedman at gmail.com
Sat Jun 21 10:25:36 PDT 2008

On Sat, Jun 21, 2008 at 8:23 AM, Argiris Kirtzidis <akyrtzi at gmail.com> wrote:
> Eli Friedman wrote:
>> A couple more potential issues that I found while re-reading the patch:
>> +    bool isInstField = (DS.getStorageClassSpec() ==
>> DeclSpec::SCS_unspecified &&
>> +                        !DeclaratorInfo.isFunctionDeclarator());
>> This check isn't reliable. Simple example: "typedef int func(); class
>> C {func a,b;};".
> Ah, good find!
> How about adding a Action::isFunctionTypeDeclarator for the parser to get
> this kind of information:

Having the parser query Sema is no good; it's a layering violation.
The expectation is that the parser works the same way no matter what
action handler it's hooked up to.  I'd suggest just verifying that the
form is legal per the grammar, and moving the logic that decides what
type we're dealing with into Sema (something like
ActOnMemberDeclarator).  There's no good reason to force checks into
the parser that it can't handle easily.


More information about the cfe-dev mailing list