]> granicus.if.org Git - clang/commitdiff
Turn on 'auto' in plain objc mode.
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Feb 2011 18:37:13 +0000 (18:37 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Feb 2011 18:37:13 +0000 (18:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126134 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/SemaObjC/auto-objective-c.m [new file with mode: 0644]

index 5a7fc7e72d06d0df46103578f227f7ec15ca921e..5e3bfe77e7ddb0d706a725b0296febfbe8d7c638 100644 (file)
@@ -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 (file)
index 0000000..e73f899
--- /dev/null
@@ -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