diff options
-rw-r--r-- | clang/lib/ARCMigrate/TransGCAttrs.cpp | 18 | ||||
-rw-r--r-- | clang/test/ARCMT/GC-check.m | 5 | ||||
-rw-r--r-- | clang/test/ARCMT/GC.h | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp index a85cad4d44a..79dc0538b69 100644 --- a/clang/lib/ARCMigrate/TransGCAttrs.cpp +++ b/clang/lib/ARCMigrate/TransGCAttrs.cpp @@ -186,10 +186,28 @@ static void clearRedundantStrongs(MigrationContext &MigrateCtx) { } } +static void errorForGCAttrsOnNonObjC(MigrationContext &MigrateCtx) { + TransformActions &TA = MigrateCtx.Pass.TA; + + for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) { + MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i]; + if (Attr.FullyMigratable && Attr.Dcl) { + if (Attr.ModifiedType.isNull()) + continue; + if (!Attr.ModifiedType->isObjCRetainableType()) { + TA.reportError("GC managed memory will become unmanaged in ARC", + Attr.Loc); + } + } + } +} + void GCAttrsTraverser::traverseTU(MigrationContext &MigrateCtx) { GCAttrsCollector(MigrateCtx).TraverseDecl( MigrateCtx.Pass.Ctx.getTranslationUnitDecl()); + clearRedundantStrongs(MigrateCtx); + errorForGCAttrsOnNonObjC(MigrateCtx); } void MigrationContext::dumpGCAttrs() { diff --git a/clang/test/ARCMT/GC-check.m b/clang/test/ARCMT/GC-check.m index f71787ce029..9864354228b 100644 --- a/clang/test/ARCMT/GC-check.m +++ b/clang/test/ARCMT/GC-check.m @@ -12,3 +12,8 @@ void test1(CFTypeRef *cft) { // expected-error {{unavailable}} NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}} } + +@interface I1 { + __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}} +} +@end; diff --git a/clang/test/ARCMT/GC.h b/clang/test/ARCMT/GC.h index 6202e478c33..4301baf2724 100644 --- a/clang/test/ARCMT/GC.h +++ b/clang/test/ARCMT/GC.h @@ -1,5 +1,6 @@ @interface ExtInterface { __strong ExtInterface *myivar; + __strong void *gcVar; } @end |