From: Fariborz Jahanian Date: Mon, 21 Feb 2011 18:37:13 +0000 (+0000) Subject: Turn on 'auto' in plain objc mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c6b0ebc33c4db48355078a45a21cb6867e298b1;p=clang Turn on 'auto' in plain objc mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126134 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 5a7fc7e72d..5e3bfe77e7 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1244,7 +1244,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, DiagID, getLang()); break; case tok::kw_auto: - if (getLang().CPlusPlus0x) + if (getLang().CPlusPlus0x || getLang().ObjC1) isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec, DiagID); else diff --git a/test/SemaObjC/auto-objective-c.m b/test/SemaObjC/auto-objective-c.m new file mode 100644 index 0000000000..e73f899ac6 --- /dev/null +++ b/test/SemaObjC/auto-objective-c.m @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -x objective-c -fblocks -fsyntax-only -verify %s + +@interface I +{ + id pi; +} +- (id) Meth; +@end + + +typedef int (^P) (int x); + +@implementation I +- (id) Meth { + auto p = [pi Meth]; + return p; +} + +- (P) bfunc { + auto my_block = ^int (int x) {return x; }; + my_block(1); + return my_block; +} +@end