Cleanup error recovery for a missing '-'|'+'

on a method declaration (radar 7822196).

llvm-svn: 102383
This commit is contained in:
Fariborz Jahanian 2010-04-26 21:18:08 +00:00
parent b7e20eb883
commit 65654df92c
2 changed files with 24 additions and 34 deletions

View File

@ -142,8 +142,8 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
// We have a class or category name - consume it.
IdentifierInfo *nameId = Tok.getIdentifierInfo();
SourceLocation nameLoc = ConsumeToken();
bool Err = false;
if (Tok.is(tok::l_paren)) { // we have a category.
if (Tok.is(tok::l_paren) &&
!isKnownToBeTypeSpecifier(GetLookAheadToken(1))) { // we have a category.
SourceLocation lparenLoc = ConsumeParen();
SourceLocation categoryLoc, rparenLoc;
IdentifierInfo *categoryId = 0;
@ -157,12 +157,6 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
categoryId = Tok.getIdentifierInfo();
categoryLoc = ConsumeToken();
}
else if (isKnownToBeTypeSpecifier(Tok)) {
// Fall thru after diagnosing for better error recovery.
Diag(Tok, diag::err_expected_minus_or_plus);
ConsumeToken();
Err = true;
}
else if (!getLang().ObjC2) {
Diag(Tok, diag::err_expected_ident); // missing category name.
return DeclPtrTy();
@ -173,7 +167,6 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
return DeclPtrTy();
}
rparenLoc = ConsumeParen();
if (!Err) {
// Next, we need to check for any protocol references.
SourceLocation LAngleLoc, EndProtoLoc;
llvm::SmallVector<DeclPtrTy, 8> ProtocolRefs;
@ -201,7 +194,6 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
ParseObjCInterfaceDeclList(CategoryType, tok::objc_not_keyword);
return CategoryType;
}
}
// Parse a class interface.
IdentifierInfo *superClassId = 0;
SourceLocation superClassLoc;
@ -242,7 +234,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
ParseObjCClassInstanceVariables(ClsType, tok::objc_protected, atLoc);
ParseObjCInterfaceDeclList(ClsType, tok::objc_interface);
return Err ? DeclPtrTy() : ClsType;
return ClsType;
}
/// The Objective-C property callback. This should be defined where

View File

@ -11,9 +11,7 @@ typedef float CGFloat;
// rdar: // 7822196
@interface A
(void) x; // expected-error {{method type specifier must start with '-' or '+'}} \
// expected-warning {{type specifier missing, defaults to 'int' [-Wimplicit-int]}} \
// expected-error {{cannot declare variable inside @interface or @protocol}}
(void) x; // expected-error {{method type specifier must start with '-' or '+'}}
(int)im; // expected-error {{method type specifier must start with '-' or '+'}} \
- ok;
@end