aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-02-22 06:58:28 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-02-22 06:58:28 +0000
commit28965bfa833926fd908a902cf2373d07c47b9067 (patch)
tree4b43bb10276686db2ad199e006c6e8ce31089fe3 /lib/Sema/SemaDeclAttr.cpp
parent150d853343758281f7b0c44e058ea81da45b79be (diff)
Don't crash when applying an alloc_size attribute on a K&R function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175867 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--lib/Sema/SemaDeclAttr.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 0a30163f99..1142e0dd2d 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1097,7 +1097,11 @@ static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
// In C++ the implicit 'this' function parameter also counts, and they are
// counted from one.
bool HasImplicitThisParam = isInstanceMethod(D);
- unsigned NumArgs = getFunctionOrMethodNumArgs(D) + HasImplicitThisParam;
+ unsigned NumArgs;
+ if (hasFunctionProto(D))
+ NumArgs = getFunctionOrMethodNumArgs(D) + HasImplicitThisParam;
+ else
+ NumArgs = 0;
SmallVector<unsigned, 8> SizeArgs;