Add test case for nonnull attribute.
Fix indexing bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53882 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 3800fa3..edf9a66 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -14,6 +14,7 @@
#include "Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/TargetInfo.h"
+#include <sstream>
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -266,10 +267,14 @@
unsigned x = (unsigned) ArgNum.getZExtValue();
if (x < 1 || x > NumArgs) {
+ std::ostringstream os;
+ os << I.getArgNum();
S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds,
- "nonnull", Ex->getSourceRange());
+ "nonnull", os.str(), Ex->getSourceRange());
return;
}
+
+ --x;
// Is the function argument a pointer type?
if (!proto->getArgType(x).getCanonicalType()->isPointerType()) {