From: Fariborz Jahanian Date: Mon, 25 Jul 2011 21:12:27 +0000 (+0000) Subject: objective-c: Provide a 'fixit' when class was used X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcf1011876d8a472aeb05617c1a84c3d74fbd7ce;p=clang objective-c: Provide a 'fixit' when class was used to declare a static object. // rdar://9603056 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135970 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 8b02390b58..d231d3ccab 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/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/test/FixIt/fixit-static-object-decl.m b/test/FixIt/fixit-static-object-decl.m new file mode 100644 index 0000000000..c9661e275e --- /dev/null +++ b/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]; +}