[cfe-commits] r135970 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/FixIt/fixit-static-object-decl.m

Fariborz Jahanian fjahanian at apple.com
Mon Jul 25 14:12:27 PDT 2011


Author: fjahanian
Date: Mon Jul 25 16:12:27 2011
New Revision: 135970

URL: http://llvm.org/viewvc/llvm-project?rev=135970&view=rev
Log:
objective-c: Provide a 'fixit' when class was used
to declare a static object. // rdar://9603056

Added:
    cfe/trunk/test/FixIt/fixit-static-object-decl.m
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=135970&r1=135969&r2=135970&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jul 25 16:12:27 2011
@@ -3937,7 +3937,8 @@
   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();
   }
 

Added: cfe/trunk/test/FixIt/fixit-static-object-decl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-static-object-decl.m?rev=135970&view=auto
==============================================================================
--- cfe/trunk/test/FixIt/fixit-static-object-decl.m (added)
+++ cfe/trunk/test/FixIt/fixit-static-object-decl.m Mon Jul 25 16:12:27 2011
@@ -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
+
+ at interface NSArray
++ (id) arrayWithObjects;
+ at end
+
+int main() {
+  	NSArray pluginNames = [NSArray arrayWithObjects];
+}





More information about the cfe-commits mailing list