diff options
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | lib/Sema/SemaExpr.cpp | 19 | 
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 14efc9672061..759c82eeaa07 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -366,8 +366,18 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,      if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))        return true; +  } -    if (diagnoseArgIndependentDiagnoseIfAttrs(FD, Loc)) +  auto getReferencedObjCProp = [](const NamedDecl *D) -> +                                      const ObjCPropertyDecl * { +    if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) +      return MD->findPropertyDecl(); +    return nullptr; +  }; +  if (const ObjCPropertyDecl *ObjCPDecl = getReferencedObjCProp(D)) { +    if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc)) +      return true; +  } else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {        return true;    } @@ -15742,6 +15752,13 @@ ExprResult Sema::ActOnObjCAvailabilityCheckExpr(    if (Spec != AvailSpecs.end())      Version = Spec->getVersion(); +  // The use of `@available` in the enclosing function should be analyzed to +  // warn when it's used inappropriately (i.e. not if(@available)). +  if (getCurFunctionOrMethodDecl()) +    getEnclosingFunction()->HasPotentialAvailabilityViolations = true; +  else if (getCurBlock() || getCurLambda()) +    getCurFunction()->HasPotentialAvailabilityViolations = true; +    return new (Context)        ObjCAvailabilityCheckExpr(Version, AtLoc, RParen, Context.BoolTy);  }  | 
