From: John McCall Date: Tue, 10 Nov 2015 23:00:25 +0000 (+0000) Subject: Define __unsafe_unretained and __autoreleasing in ObjC GC mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfa180d5903d1740e12a979305e164e52519910a;p=clang Define __unsafe_unretained and __autoreleasing in ObjC GC mode. This was an accidental regression from the MRC __weak patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252668 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index c82e897418..30bf118bc2 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -867,6 +867,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, LangOpts.getGC() != LangOptions::NonGC) { Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))"); Builder.defineMacro("__strong", "__attribute__((objc_gc(strong)))"); + Builder.defineMacro("__autoreleasing", ""); + Builder.defineMacro("__unsafe_unretained", ""); } else if (LangOpts.ObjC1) { Builder.defineMacro("__weak", "__attribute__((objc_ownership(weak)))"); Builder.defineMacro("__strong", "__attribute__((objc_ownership(strong)))"); diff --git a/test/SemaObjC/gc-attributes.m b/test/SemaObjC/gc-attributes.m index 2f5432842e..1023ba6eec 100644 --- a/test/SemaObjC/gc-attributes.m +++ b/test/SemaObjC/gc-attributes.m @@ -20,3 +20,7 @@ void test_f1() { f1(&a); f1(&a2); // expected-warning{{passing 'A *__strong *' to parameter of type 'A *__weak *' discards qualifiers}} } + +// These qualifiers should silently expand to nothing in GC mode. +void test_unsafe_unretained(__unsafe_unretained id *x) {} +void test_autoreleasing(__autoreleasing id *x) {}