diff options
author | Chris Lattner <sabre@nondot.org> | 2008-06-21 19:39:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-06-21 19:39:06 +0000 |
commit | 535b8304496e3156a86d4ddde1179bfad5cffdf0 (patch) | |
tree | 1c0d5f19f1f744dc65cc8cbbc9bead2c3ed64dc1 /clang/lib/Parse/ParseDecl.cpp | |
parent | 14b911d92971e3205cd019efe6879b8219c83f78 (diff) | |
download | bcm5719-llvm-535b8304496e3156a86d4ddde1179bfad5cffdf0.tar.gz bcm5719-llvm-535b8304496e3156a86d4ddde1179bfad5cffdf0.zip |
add parser and sema support for the funny ObjC '@defs' thing.
Patch by David Chisnall!
llvm-svn: 52586
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 46246e64bac..95344c438ef 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -707,7 +707,7 @@ ParseStructDeclaration(DeclSpec &DS, /// struct-declaration-list: /// struct-declaration /// struct-declaration-list struct-declaration -/// [OBC] '@' 'defs' '(' class-name ')' [TODO] +/// [OBC] '@' 'defs' '(' class-name ')' /// void Parser::ParseStructUnionBody(SourceLocation RecordLoc, unsigned TagType, DeclTy *TagDecl) { @@ -736,18 +736,39 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, // Parse all the comma separated declarators. DeclSpec DS; FieldDeclarators.clear(); - ParseStructDeclaration(DS, FieldDeclarators); - - // Convert them all to fields. - for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) { - FieldDeclarator &FD = FieldDeclarators[i]; - // Install the declarator into the current TagDecl. - DeclTy *Field = Actions.ActOnField(CurScope, - DS.getSourceRange().getBegin(), - FD.D, FD.BitfieldSize); - FieldDecls.push_back(Field); - } - + if (!Tok.is(tok::at)) { + ParseStructDeclaration(DS, FieldDeclarators); + + // Convert them all to fields. + for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) { + FieldDeclarator &FD = FieldDeclarators[i]; + // Install the declarator into the current TagDecl. + DeclTy *Field = Actions.ActOnField(CurScope, + DS.getSourceRange().getBegin(), + FD.D, FD.BitfieldSize); + FieldDecls.push_back(Field); + } + } else { // Handle @defs + ConsumeToken(); + if (!Tok.isObjCAtKeyword(tok::objc_defs)) { + Diag(Tok, diag::err_unexpected_at); + SkipUntil(tok::semi, true, true); + continue; + } + ConsumeToken(); + ExpectAndConsume(tok::l_paren, diag::err_expected_lparen); + if (!Tok.is(tok::identifier)) { + Diag(Tok, diag::err_expected_ident); + SkipUntil(tok::semi, true, true); + continue; + } + llvm::SmallVector<DeclTy*, 16> Fields; + Actions.ActOnDefs(CurScope, Tok.getLocation(), Tok.getIdentifierInfo(), + Fields); + FieldDecls.insert(FieldDecls.end(), Fields.begin(), Fields.end()); + ConsumeToken(); + ExpectAndConsume(tok::r_paren, diag::err_expected_rparen); + } if (Tok.is(tok::semi)) { ConsumeToken(); |