objective-c: Provide a 'fixit' when class was used

to declare a static object. // rdar://9603056

llvm-svn: 135970
This commit is contained in:
Fariborz Jahanian 2011-07-25 21:12:27 +00:00
parent d48db2115a
commit 9a14c21cfd
2 changed files with 20 additions and 1 deletions

View 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();
}

View File

@ -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];
}