This patch finishes off the sentinel attribute handling for
blocks and function pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71888 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index c253b40..f5b6595 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -726,11 +726,9 @@
;
} else if (const VarDecl *V = dyn_cast<VarDecl>(d)) {
QualType Ty = V->getType();
- if (Ty->isBlockPointerType()) {
- const BlockPointerType *BPT = Ty->getAsBlockPointerType();
- QualType FnType = BPT->getPointeeType();
- const FunctionType *FT = FnType->getAsFunctionType();
- assert(FT && "Block has non-function type?");
+ if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
+ const FunctionType *FT = Ty->isFunctionPointerType() ? getFunctionType(d)
+ : Ty->getAsBlockPointerType()->getPointeeType()->getAsFunctionType();
if (!cast<FunctionProtoType>(FT)->isVariadic()) {
S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic);
return;