From 8c6519a6e4ed20a9f8cbd32e6454cb0fb556186b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 22 Jan 2007 07:41:36 +0000 Subject: [PATCH] invoke a new callback when starting to parse a struct/union tag llvm-svn: 39268 --- clang/Parse/ParseDecl.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/clang/Parse/ParseDecl.cpp b/clang/Parse/ParseDecl.cpp index 2727044bce03..2aa36e52f6bb 100644 --- a/clang/Parse/ParseDecl.cpp +++ b/clang/Parse/ParseDecl.cpp @@ -439,12 +439,24 @@ void Parser::ParseStructUnionSpecifier(DeclSpec &DS) { if (Tok.getKind() != tok::identifier && Tok.getKind() != tok::l_brace) { Diag(Tok, diag::err_expected_ident_lbrace); + // TODO: better error recovery here. return; } - if (Tok.getKind() == tok::identifier) - ConsumeToken(); + // If an identifier is present, consume and remember it. + IdentifierInfo *Name = 0; + SourceLocation NameLoc; + if (Tok.getKind() == tok::identifier) { + Name = Tok.getIdentifierInfo(); + NameLoc = ConsumeToken(); + } + // There are three options here. If we have 'struct foo;', then this is a + // forward declaration. If we have 'struct foo {...' then this is a + // definition. Otherwise we have something like 'struct foo xyz', a use. + DeclTy *TagDecl = Actions.ParseStructUnionTag(CurScope, isUnion, StartLoc, + Name, NameLoc); + // TODO: more with the tag decl. if (Tok.getKind() == tok::l_brace) { SourceLocation LBraceLoc = ConsumeBrace();