From 786e04cda550902257eda6c489a62bdf9abeaaea Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 21 Feb 2011 18:37:13 +0000 Subject: [PATCH] Turn on 'auto' in plain objc mode. llvm-svn: 126134 --- clang/lib/Parse/ParseDecl.cpp | 2 +- clang/test/SemaObjC/auto-objective-c.m | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaObjC/auto-objective-c.m diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 5a7fc7e72d06..5e3bfe77e7dd 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/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/clang/test/SemaObjC/auto-objective-c.m b/clang/test/SemaObjC/auto-objective-c.m new file mode 100644 index 000000000000..e73f899ac6b3 --- /dev/null +++ b/clang/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 -- GitLab