diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 11 | ||||
-rw-r--r-- | test/SemaObjC/arc.m | 6 |
3 files changed, 21 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 2988f11898..d5567d5fdc 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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 { diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 79afbe538d..940f5a86a6 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -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(); diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m index 7fc606bde9..dc5a1fe922 100644 --- a/test/SemaObjC/arc.m +++ b/test/SemaObjC/arc.m @@ -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}} |