summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-07-26 00:20:22 +0000
committerChris Lattner <sabre@nondot.org>2008-07-26 00:20:22 +0000
commit0974b2380f555333aa34125e870e0620af8d11fe (patch)
tree6613d4ece518efb1b3baf80baf89a1a35b80de5b /clang/lib/Parse/ParseDecl.cpp
parent9acd2f1cd2d2f00534b5e5195af603314eca69a4 (diff)
downloadbcm5719-llvm-0974b2380f555333aa34125e870e0620af8d11fe.tar.gz
bcm5719-llvm-0974b2380f555333aa34125e870e0620af8d11fe.zip
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. llvm-svn: 54082
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 1ac26a309fa..c9e64f4c224 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud