]> granicus.if.org Git - clang/commitdiff
objc arc: Suppress certain arc diagnostics on unavailable
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 3 Oct 2011 22:11:57 +0000 (22:11 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 3 Oct 2011 22:11:57 +0000 (22:11 +0000)
functions. // rdar://10186536

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

lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
test/SemaObjC/arc.m

index 2988f118986d59725d38ae0d6eb8f77d9e9ae1ef..d5567d5fdc56b578f11e3ab4e4bc3b3d98065247 100644 (file)
@@ -33,6 +33,7 @@
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 // FIXME: layering (ideally, Sema shouldn't be dependent on Lex API's)
@@ -6572,8 +6573,9 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc,
     //   - otherwise, it's an error
     if (T->isArrayType()) {
       if (!T.isConstQualified()) {
-        Diag(NameLoc, diag::err_arc_array_param_no_ownership)
-          << TSInfo->getTypeLoc().getSourceRange();
+        DelayedDiagnostics.add(
+            sema::DelayedDiagnostic::makeForbiddenType(
+            NameLoc, diag::err_arc_array_param_no_ownership, T, false));
       }
       lifetime = Qualifiers::OCL_ExplicitNone;
     } else {
index 79afbe538d3d920d34b38ea2f901d4f119878cc5..940f5a86a61e98657cf21add183785a8763ef314 100644 (file)
@@ -3904,6 +3904,17 @@ static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &diag,
                         "this system declaration uses an unsupported type"));
     return;
   }
+  if (S.getLangOptions().ObjCAutoRefCount)
+    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(decl)) {
+      // FIXME. we may want to supress diagnostics for all
+      // kind of forbidden type messages on unavailable functions. 
+      if (FD->hasAttr<UnavailableAttr>() &&
+          diag.getForbiddenTypeDiagnostic() == 
+          diag::err_arc_array_param_no_ownership) {
+        diag.Triggered = true;
+        return;
+      }
+    }
 
   S.Diag(diag.Loc, diag.getForbiddenTypeDiagnostic())
     << diag.getForbiddenTypeOperand() << diag.getForbiddenTypeArgument();
index 7fc606bde968fc70da3ccf9726616f56e5d82100..dc5a1fe9220839e8b2d4e2bc58a5006de36c6292 100644 (file)
@@ -662,3 +662,9 @@ void test38() {
     ;
   }
 }
+
+// rdar://10186536
+@class NSColor;
+void _NSCalc(NSColor* color, NSColor* bezelColors[]) __attribute__((unavailable("not available in automatic reference counting mode")));
+
+void _NSCalcBeze(NSColor* color, NSColor* bezelColors[]); // expected-error {{must explicitly describe intended ownership of an object array parameter}}