"__attribute ((NSObject)) may be put on a typedef only, "
"attribute is ignored">, InGroup<NSobjectAttribute>;
def warn_attribute_weak_on_local : Warning<
- "__weak attribute cannot be specified on an automatic variable">,
+ "__weak attribute cannot be specified on an automatic variable when ARC "
+ "is not enabled">,
InGroup<IgnoredAttributes>;
def warn_weak_identifier_undeclared : Warning<
"weak identifier %0 never declared">;
&& !NewVD->hasAttr<BlocksAttr>()) {
if (getLangOpts().getGC() != LangOptions::NonGC)
Diag(NewVD->getLocation(), diag::warn_gc_attribute_weak_on_local);
- else
+ else {
+ assert(!getLangOpts().ObjCAutoRefCount);
Diag(NewVD->getLocation(), diag::warn_attribute_weak_on_local);
+ }
}
bool isVM = T->isVariablyModifiedType();
--- /dev/null
+// RUN: %clang -fsyntax-only -Wunused-function %s > %t.nonarc 2>&1
+// RUN: %clang -fsyntax-only -Wunused-function -fobjc-arc %s > %t.arc 2>&1
+// RUN: FileCheck -input-file=%t.nonarc %s
+// RUN: FileCheck -input-file=%t.arc -check-prefix=ARC %s
+
+static void bar() {} // Intentionally unused.
+
+void foo(id self) {
+ __weak id weakSelf = self;
+}
+
+// CHECK: 9:13: warning: __weak attribute cannot be specified on an automatic variable when ARC is not enabled
+// CHECK: 6:13: warning: unused function 'bar'
+// CHECK: 2 warnings generated
+// ARC: 6:13: warning: unused function 'bar'
+// ARC: 1 warning generated