[cfe-dev] ParseTag only called from ParseEnumSpecifier
Argiris Kirtzidis
akyrtzi at gmail.com
Thu Sep 4 16:30:48 PDT 2008
Doug Gregor wrote:
> On Wed, Sep 3, 2008 at 2:36 PM, Ted Kremenek <kremenek at apple.com> wrote:
>
>> As a side note, my original interest in this code was to allow the
>> parser+actions to be able to distinguish up front between enum/struct/
>> union/class forward declarations and definitions.
>>
>
> FWIW, this requires arbitrary lookahead in C++ (but not in C), since
> we can't tell the difference between a class-specifier and an
> elaborated-type-specifier until we've parsed through the
> nested-name-specifier and hit the actual class identifier (or
> template-id). Of course, one could apply Argiris' pre-parser idea to
> do the disambiguation between these two nonterminals in advance.
>
In an attempt at parsing nested-name-specifiers, inside
ParseClassSpecifier, the parser would parse the nested-name-specifier,
get it resolved to a CXXScopeTy* by Sema, and pass this pointer to
ActOnTag along with the other information (identifier etc.). That way
there's no need for lookahead.
On Wed, Sep 3, 2008 at 2:36 PM, Ted Kremenek <kremenek at apple.com> wrote:
> As a side note, my original interest in this code was to allow the
> parser+actions to be able to distinguish up front between enum/struct/
> union/class forward declarations and definitions.
>
Doesn't already the parser+actions distinguish them ? ActOnTag gets passed a TagKind which is one of TK_Definition/TK_Declaration/TK_Reference.
-Argiris
More information about the cfe-dev
mailing list