diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 8b02390b58ac..d231d3ccabfe 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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/clang/test/FixIt/fixit-static-object-decl.m b/clang/test/FixIt/fixit-static-object-decl.m new file mode 100644 index 000000000000..c9661e275e00 --- /dev/null +++ b/clang/test/FixIt/fixit-static-object-decl.m @@ -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]; +}