]> granicus.if.org Git - clang/commitdiff
objective-c: Provide a 'fixit' when class was used
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 25 Jul 2011 21:12:27 +0000 (21:12 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 25 Jul 2011 21:12:27 +0000 (21:12 +0000)
to declare a static object. // rdar://9603056

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135970 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/FixIt/fixit-static-object-decl.m [new file with mode: 0644]

index 8b02390b58ac23b4d8e94e7c6394a81471726ba7..d231d3ccabfedc3b49ac8e790681e1d9d78fb1e9 100644 (file)
@@ -3937,7 +3937,8 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD,
   QualType T = NewVD->getType();
 
   if (T->isObjCObjectType()) {
-    Diag(NewVD->getLocation(), diag::err_statically_allocated_object);
+    Diag(NewVD->getLocation(), diag::err_statically_allocated_object)
+      << FixItHint::CreateInsertion(NewVD->getLocation(), "*");
     return NewVD->setInvalidDecl();
   }
 
diff --git a/test/FixIt/fixit-static-object-decl.m b/test/FixIt/fixit-static-object-decl.m
new file mode 100644 (file)
index 0000000..c9661e2
--- /dev/null
@@ -0,0 +1,18 @@
+// Objective-C recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fixit -x objective-c %t || true
+// RUN: %clang_cc1 -fsyntax-only -Werror -x objective-c %t
+
+// Objective-C++ recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fixit -x objective-c++ %t || true
+// RUN: %clang_cc1 -fsyntax-only -Werror -x objective-c++ %t
+// rdar://9603056
+
+@interface NSArray
++ (id) arrayWithObjects;
+@end
+
+int main() {
+       NSArray pluginNames = [NSArray arrayWithObjects];
+}