From 7bf952e60114bbe54b25c4fe7379e7db097695e7 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 22 Jun 2011 18:03:59 +0000 Subject: [PATCH] [arcmt] Make -Warc-unsafe-retained-assign an error when migrating. rdar://8939557 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133627 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/ARCMT.cpp | 2 ++ test/ARCMT/checking.m | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index 13bb33d2b8..7f3479604e 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -187,6 +187,8 @@ CompilerInvocation *createInvocationForMigration(CompilerInvocation &origCI) { CInvok->getPreprocessorOpts().addMacroDef(define); CInvok->getLangOpts().ObjCAutoRefCount = true; CInvok->getDiagnosticOpts().ErrorLimit = 0; + CInvok->getDiagnosticOpts().Warnings.push_back( + "error=arc-unsafe-retained-assign"); CInvok->getLangOpts().ObjCNoAutoRefCountRuntime = !HasARCRuntime(origCI); return CInvok.take(); diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m index 62387fa23b..8ee7e80bed 100644 --- a/test/ARCMT/checking.m +++ b/test/ARCMT/checking.m @@ -253,3 +253,15 @@ void rdar9491791(int p) { void rdar9504750(id p) { RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} } + +// rdar://8939557 +@interface TestReadonlyProperty : NSObject +@property(assign,readonly) NSObject *value; +@end + +@implementation TestReadonlyProperty +@synthesize value; +- (void)viewDidLoad { + value = [NSObject new]; // expected-error {{assigning retained object}} +} +@end -- 2.40.0