From 47b1517c52c229f50f76b86a99904e00a77901f8 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 19 Jul 2013 18:57:15 +0000 Subject: [PATCH] [arcmt] After checking is successful disable auto-synthesize to avoid "@synthesize of 'weak' property is only allowed in ARC" errors. rdar://14461559 llvm-svn: 186709 --- clang/lib/ARCMigrate/ARCMT.cpp | 3 +++ clang/test/ARCMT/checking-in-arc.m | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 clang/test/ARCMT/checking-in-arc.m diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp index a6d4876..8a2b939 100644 --- a/clang/lib/ARCMigrate/ARCMT.cpp +++ b/clang/lib/ARCMigrate/ARCMT.cpp @@ -324,6 +324,9 @@ bool arcmt::checkForManualIssues(CompilerInvocation &origCI, // If we are migrating code that gets the '-fobjc-arc' flag, make sure // to remove it so that we don't get errors from normal compilation. origCI.getLangOpts()->ObjCAutoRefCount = false; + // Disable auto-synthesize to avoid "@synthesize of 'weak' property is only + // allowed in ARC" errors. + origCI.getLangOpts()->ObjCDefaultSynthProperties = false; return capturedDiags.hasErrors() || testAct.hasReportedErrors(); } diff --git a/clang/test/ARCMT/checking-in-arc.m b/clang/test/ARCMT/checking-in-arc.m new file mode 100644 index 0000000..5a1b3d3 --- /dev/null +++ b/clang/test/ARCMT/checking-in-arc.m @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -arcmt-check -fobjc-arc -fobjc-default-synthesize-properties -fobjc-runtime=macosx-10.8.0 -triple x86_64-apple-darwin12 -fblocks -Werror %s +// DISABLE: mingw32 + +#if __has_feature(objc_arc) +#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) +#else +#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE +#endif + +typedef const void * CFTypeRef; +CFTypeRef CFBridgingRetain(id X); +id CFBridgingRelease(CFTypeRef); + +typedef int BOOL; +typedef unsigned NSUInteger; + +@protocol NSObject +- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +@end + +@interface NSObject {} +- (id)init; + ++ (id)new; ++ (id)alloc; +- (void)dealloc; + +- (void)finalize; + +- (id)copy; +- (id)mutableCopy; +@end + +typedef const struct __CFString * CFStringRef; +extern const CFStringRef kUTTypePlainText; +extern const CFStringRef kUTTypeRTF; +@class NSString; + +@interface Test : NSObject +@property (weak) NSString *weakProperty; +@end + +@implementation Test +@end -- 2.7.4