don't crash when sentinel attribute is used on function without a prototype,
discovered as part of PR3817
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67127 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 57cd3d2..9681201 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -687,8 +687,15 @@
}
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
- QualType FT = FD->getType();
- if (!FT->getAsFunctionProtoType()->isVariadic()) {
+ const FunctionType *FT = FD->getType()->getAsFunctionType();
+ assert(FT && "FunctionDecl has non-function type?");
+
+ if (isa<FunctionNoProtoType>(FT)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_named_arguments);
+ return;
+ }
+
+ if (!cast<FunctionProtoType>(FT)->isVariadic()) {
S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic);
return;
}