diff options
author | Chris Lattner <sabre@nondot.org> | 2008-07-26 00:20:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-07-26 00:20:22 +0000 |
commit | bce6135441fd489527a9ad1776d0472335be596d (patch) | |
tree | d5fe1556c2236bd5e6fa262ae31641424bb4ccc7 /lib/Parse/ParseDecl.cpp | |
parent | 844cef32e4359c3e651e4eb84beca0c3e8a727d5 (diff) |
improve handling of the horrible GCC objc extension that treats "<foo>"
like "id<foo>". This 1) fixes an infinite loop in the parser on things
like "short<foo>" 2) emits a warning about this bogus construct and 3)
changes the testcase to be substantially reduced.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 1ac26a309f..c9e64f4c22 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -430,6 +430,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) { } // FALL THROUGH. default: + DoneWithDeclSpec: // If this is not a declaration specifier token, we're done reading decl // specifiers. First verify that DeclSpec's are consistent. DS.Finish(Diags, PP.getSourceManager(), getLang()); @@ -552,20 +553,27 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) { 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; + // GCC supports types like "<SomeProtocol>" as a synonym for + // "id<SomeProtocol>". This is hopelessly old fashioned and dangerous, + // but we support it. + if (DS.hasTypeSpecifier()) + goto DoneWithDeclSpec; + + { + SourceLocation EndProtoLoc; llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs; - ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc); + ParseObjCProtocolReferences(ProtocolRefs, EndProtoLoc); llvm::SmallVector<DeclTy *, 8> *ProtocolDecl = new llvm::SmallVector<DeclTy *, 8>; DS.setProtocolQualifiers(ProtocolDecl); Actions.FindProtocolDeclaration(Loc, - &ProtocolRefs[0], ProtocolRefs.size(), - *ProtocolDecl); + &ProtocolRefs[0], ProtocolRefs.size(), + *ProtocolDecl); + Diag(Loc, diag::warn_objc_protocol_qualifier_missing_id, + SourceRange(Loc, EndProtoLoc)); + continue; } - continue; } // If the specifier combination wasn't legal, issue a diagnostic. if (isInvalid) { |