]> granicus.if.org Git - clang/commitdiff
When applying ARC __weak to a non-objc pointer, do not give error that
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 7 Nov 2011 18:40:21 +0000 (18:40 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 7 Nov 2011 18:40:21 +0000 (18:40 +0000)
__weak is unsupported by the deployment target, since it is going to be
ignored anyway.

Makes it easier for incremental migration from GC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143975 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/SemaObjC/arc-no-runtime.m

index 219a9e8a3085a614b50c4c46e41f07fa10e9fe66..4dc6c949d59ca48ffa01429a074e1791a6b488a6 100644 (file)
@@ -3341,7 +3341,7 @@ static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state,
 
   // Forbid __weak if the runtime doesn't support it.
   if (lifetime == Qualifiers::OCL_Weak &&
-      !S.getLangOptions().ObjCRuntimeHasWeak) {
+      !S.getLangOptions().ObjCRuntimeHasWeak && !NonObjCPointer) {
 
     // Actually, delay this until we know what we're parsing.
     if (S.DelayedDiagnostics.shouldDelayDiagnostics()) {
index 49c439b167605981895d6712dbcf1496f1f283ee..567dc68cd681d86ca44146398be69a54a44d7065 100644 (file)
@@ -3,6 +3,7 @@
 // rdar://problem/9150784
 void test(void) {
   __weak id x; // expected-error {{the current deployment target does not support automated __weak references}}
+  __weak void *v; // expected-warning {{'__weak' only applies to objective-c object or block pointer types}}
 }
 
 @interface A