[llvm-branch-commits] [cfe-branch] r119825 - in /cfe/branches/Apple/whitney: include/clang/Parse/Parser.h lib/Parse/ParseDecl.cpp lib/Parse/ParseObjc.cpp test/Parser/placeholder-recovery.m
Daniel Dunbar
daniel at zuster.org
Fri Nov 19 11:49:47 PST 2010
Author: ddunbar
Date: Fri Nov 19 13:49:47 2010
New Revision: 119825
URL: http://llvm.org/viewvc/llvm-project?rev=119825&view=rev
Log:
Merge r119805:
--
Author: Douglas Gregor <dgregor at apple.com>
Date: Fri Nov 19 17:10:50 2010 +0000
When parsing something that looks like an ill-formed
protocol-qualifier list without a leading type (e.g., <#blah#>), don't
complain about it being an archaic protocol-qualifier list unless it
actually parses as one.
Added:
cfe/branches/Apple/whitney/test/Parser/placeholder-recovery.m
Modified:
cfe/branches/Apple/whitney/include/clang/Parse/Parser.h
cfe/branches/Apple/whitney/lib/Parse/ParseDecl.cpp
cfe/branches/Apple/whitney/lib/Parse/ParseObjc.cpp
Modified: cfe/branches/Apple/whitney/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Parse/Parser.h?rev=119825&r1=119824&r2=119825&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Parse/Parser.h (original)
+++ cfe/branches/Apple/whitney/include/clang/Parse/Parser.h Fri Nov 19 13:49:47 2010
@@ -951,7 +951,7 @@
bool WarnOnDeclarations,
SourceLocation &LAngleLoc,
SourceLocation &EndProtoLoc);
- void ParseObjCProtocolQualifiers(DeclSpec &DS);
+ bool ParseObjCProtocolQualifiers(DeclSpec &DS);
void ParseObjCInterfaceDeclList(Decl *interfaceDecl,
tok::ObjCKeywordKind contextKey);
Decl *ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
Modified: cfe/branches/Apple/whitney/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Parse/ParseDecl.cpp?rev=119825&r1=119824&r2=119825&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Parse/ParseDecl.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Parse/ParseDecl.cpp Fri Nov 19 13:49:47 2010
@@ -1426,11 +1426,10 @@
if (DS.hasTypeSpecifier() || !getLang().ObjC1)
goto DoneWithDeclSpec;
- ParseObjCProtocolQualifiers(DS);
-
- Diag(Loc, diag::warn_objc_protocol_qualifier_missing_id)
- << FixItHint::CreateInsertion(Loc, "id")
- << SourceRange(Loc, DS.getSourceRange().getEnd());
+ if (!ParseObjCProtocolQualifiers(DS))
+ Diag(Loc, diag::warn_objc_protocol_qualifier_missing_id)
+ << FixItHint::CreateInsertion(Loc, "id")
+ << SourceRange(Loc, DS.getSourceRange().getEnd());
// Need to support trailing type qualifiers (e.g. "id<p> const").
// If a type specifier follows, it will be diagnosed elsewhere.
Modified: cfe/branches/Apple/whitney/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Parse/ParseObjc.cpp?rev=119825&r1=119824&r2=119825&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Parse/ParseObjc.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Parse/ParseObjc.cpp Fri Nov 19 13:49:47 2010
@@ -1038,18 +1038,19 @@
/// \brief Parse the Objective-C protocol qualifiers that follow a typename
/// in a decl-specifier-seq, starting at the '<'.
-void Parser::ParseObjCProtocolQualifiers(DeclSpec &DS) {
+bool Parser::ParseObjCProtocolQualifiers(DeclSpec &DS) {
assert(Tok.is(tok::less) && "Protocol qualifiers start with '<'");
assert(getLang().ObjC1 && "Protocol qualifiers only exist in Objective-C");
SourceLocation LAngleLoc, EndProtoLoc;
llvm::SmallVector<Decl *, 8> ProtocolDecl;
llvm::SmallVector<SourceLocation, 8> ProtocolLocs;
- ParseObjCProtocolReferences(ProtocolDecl, ProtocolLocs, false,
- LAngleLoc, EndProtoLoc);
+ bool Result = ParseObjCProtocolReferences(ProtocolDecl, ProtocolLocs, false,
+ LAngleLoc, EndProtoLoc);
DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size(),
ProtocolLocs.data(), LAngleLoc);
if (EndProtoLoc.isValid())
DS.SetRangeEnd(EndProtoLoc);
+ return Result;
}
Added: cfe/branches/Apple/whitney/test/Parser/placeholder-recovery.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Parser/placeholder-recovery.m?rev=119825&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/Parser/placeholder-recovery.m (added)
+++ cfe/branches/Apple/whitney/test/Parser/placeholder-recovery.m Fri Nov 19 13:49:47 2010
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: We could do much better with this, if we recognized
+// placeholders somehow. However, we're content with not generating
+// bogus 'archaic' warnings with bad location info.
+ at protocol <#protocol name#> <NSObject> // expected-error 2{{expected identifier}} \
+// expected-error{{cannot find protocol declaration for 'NSObject'}} \
+// expected-warning{{protocol qualifiers without 'id'}}
+
+<#methods#> // expected-error{{expected identifier}}
+
+ at end // expected-error{{prefix attribute}}
More information about the llvm-branch-commits
mailing list