Issue warning if method body starts with a semicolon.

Fixes 
<rdar://problem/7308503> clang should disallow the trailing semicolon in method definitions

llvm-svn: 84645
This commit is contained in:
Fariborz Jahanian 2009-10-20 16:39:13 +00:00
parent bb4568a37d
commit 040d75d9b6
4 changed files with 9 additions and 3 deletions

View File

@ -201,6 +201,9 @@ def warn_expected_implementation : Warning<
"@end must appear in an @implementation context">;
def error_property_ivar_decl : Error<
"property synthesize requires specification of an ivar">;
def warn_semicolon_before_method_nody : Warning<
"semicolon at start of method definition is ignored">,
InGroup<DiagGroup<"semicolon-at-method-body">>;
def err_expected_field_designator : Error<
"expected a field designator, such as '.field = 4'">;

View File

@ -1371,8 +1371,11 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDefinition() {
"parsing Objective-C method");
// parse optional ';'
if (Tok.is(tok::semi))
if (Tok.is(tok::semi)) {
if (ObjCImpDecl)
Diag(Tok, diag::warn_semicolon_before_method_nody);
ConsumeToken();
}
// We should have an opening brace now.
if (Tok.isNot(tok::l_brace)) {

View File

@ -29,7 +29,7 @@
@end
@implementation Subclass
- (NSString *)token;
- (NSString *)token; // expected-warning {{semicolon at start of method definition is ignored}}
{
NSMutableString *result = nil;

View File

@ -30,7 +30,7 @@ typedef struct _NSZone NSZone;
@end
@implementation XCRefactoringTransformation
- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError; {
- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError {
@try {}
// the exception name is optional (weird)
@catch (NSException *) {}