diff options
author | Steve Naroff <snaroff@apple.com> | 2008-06-05 00:02:44 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-06-05 00:02:44 +0000 |
commit | cfdf6166fcf3cc9e989e82e026cfa2015762f7ee (patch) | |
tree | 8624b83b7c4a798616719bd80cf5131f96b6d042 /clang/lib/Parse/ParseDecl.cpp | |
parent | 976b1eee816cdb14a19ca88db0289d877dd034f2 (diff) | |
download | bcm5719-llvm-cfdf6166fcf3cc9e989e82e026cfa2015762f7ee.tar.gz bcm5719-llvm-cfdf6166fcf3cc9e989e82e026cfa2015762f7ee.zip |
Support "<p>" as a short-hand for "id<p>". Here's a comment from GCC (the only documentation I could find on it).
/* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>" - nisse@lysator.liu.se. */
This commit adds the parser magic. The type associated with <p> is still incorrect. Will discuss with Chris.
llvm-svn: 51972
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index f20c72e61ce..46246e64bac 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -323,7 +323,7 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS) { // Validate declspec for type-name. unsigned Specs = DS.getParsedSpecifiers(); - if (Specs == DeclSpec::PQ_None) + if (Specs == DeclSpec::PQ_None && !DS.getNumProtocolQualifiers()) Diag(Tok, diag::err_typename_requires_specqual); // Issue diagnostic and remove storage class if present. @@ -548,6 +548,21 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) { case tok::kw_inline: isInvalid = DS.SetFunctionSpecInline(Loc, PrevSpec); break; + + // Gross GCC-ism that we are forced support. FIXME: make an extension? + case tok::less: + if (!DS.hasTypeSpecifier()) { + SourceLocation endProtoLoc; + llvm::SmallVector<IdentifierInfo *, 8> ProtocolRefs; + ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc); + llvm::SmallVector<DeclTy *, 8> *ProtocolDecl = + new llvm::SmallVector<DeclTy *, 8>; + DS.setProtocolQualifiers(ProtocolDecl); + Actions.FindProtocolDeclaration(Loc, + &ProtocolRefs[0], ProtocolRefs.size(), + *ProtocolDecl); + } + continue; } // If the specifier combination wasn't legal, issue a diagnostic. if (isInvalid) { @@ -872,6 +887,8 @@ bool Parser::isTypeSpecifierQualifier() const { case tok::kw___attribute: // GNU typeof support. case tok::kw_typeof: + // GNU bizarre protocol extension. FIXME: make an extension? + case tok::less: // type-specifiers case tok::kw_short: @@ -962,6 +979,9 @@ bool Parser::isDeclarationSpecifier() const { // GNU attributes. case tok::kw___attribute: + + // GNU bizarre protocol extension. FIXME: make an extension? + case tok::less: return true; // typedef-name |