implement support for attribute(unavailable) on objc methods.

This implements gcc/testsuite/objc.dg/method-attribute-1.m

llvm-svn: 64581
This commit is contained in:
Chris Lattner 2009-02-15 07:50:52 +00:00
parent 8de90f0a92
commit 37959570af
1 changed files with 24 additions and 8 deletions

View File

@ -268,8 +268,12 @@ Sema::ExprResult Sema::ActOnClassMessage(
if (!Method) if (!Method)
Method = ClassDecl->lookupInstanceMethod(Sel); Method = ClassDecl->lookupInstanceMethod(Sel);
if (Method && Method->getAttr<DeprecatedAttr>()) if (Method) {
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName(); if (Method->getAttr<DeprecatedAttr>())
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
if (Method->getAttr<UnavailableAttr>())
Diag(receiverLoc, diag::warn_unavailable) << Method->getDeclName();
}
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, true, if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, true,
lbrac, rbrac, returnType)) lbrac, rbrac, returnType))
@ -316,8 +320,12 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
Method = SuperDecl->lookupInstanceMethod(Sel); Method = SuperDecl->lookupInstanceMethod(Sel);
} }
if (Method && Method->getAttr<DeprecatedAttr>()) if (Method) {
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName(); if (Method->getAttr<DeprecatedAttr>())
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
if (Method->getAttr<UnavailableAttr>())
Diag(receiverLoc, diag::warn_unavailable) << Method->getDeclName();
}
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false, if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,
lbrac, rbrac, returnType)) lbrac, rbrac, returnType))
@ -350,8 +358,12 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
ObjCImplementations[ClassDecl->getIdentifier()]) ObjCImplementations[ClassDecl->getIdentifier()])
Method = ImpDecl->getClassMethod(Sel); Method = ImpDecl->getClassMethod(Sel);
if (Method && Method->getAttr<DeprecatedAttr>()) if (Method) {
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName(); if (Method->getAttr<DeprecatedAttr>())
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
if (Method->getAttr<UnavailableAttr>())
Diag(receiverLoc, diag::warn_unavailable) << Method->getDeclName();
}
} }
if (!Method) if (!Method)
Method = FactoryMethodPool[Sel].Method; Method = FactoryMethodPool[Sel].Method;
@ -403,8 +415,12 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
Diag(lbrac, diag::warn_method_not_found_in_protocol) Diag(lbrac, diag::warn_method_not_found_in_protocol)
<< Sel << SourceRange(lbrac, rbrac); << Sel << SourceRange(lbrac, rbrac);
if (Method && Method->getAttr<DeprecatedAttr>()) if (Method) {
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName(); if (Method->getAttr<DeprecatedAttr>())
Diag(receiverLoc, diag::warn_deprecated) << Method->getDeclName();
if (Method->getAttr<UnavailableAttr>())
Diag(receiverLoc, diag::warn_unavailable) << Method->getDeclName();
}
} else { } else {
Diag(lbrac, diag::error_bad_receiver_type) Diag(lbrac, diag::error_bad_receiver_type)
<< RExpr->getType() << RExpr->getSourceRange(); << RExpr->getType() << RExpr->getSourceRange();