aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-07-28 06:52:18 +0000
committerJohn McCall <rjmccall@apple.com>2009-07-28 06:52:18 +0000
commitefadb7768e7c7418185f5a4010ecd8b21ca9731b (patch)
tree7f361b2c0a48063d2c69a613aa2ce87815650a35 /lib/Sema/SemaType.cpp
parent68a049cab6015a7437bec5661601b7d37d23c70c (diff)
Bounds checking for address spaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77303 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 226f214391..d3daa07a9c 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -1469,6 +1469,23 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type,
return;
}
+ // Bounds checking.
+ if (addrSpace.isSigned()) {
+ if (addrSpace.isNegative()) {
+ S.Diag(Attr.getLoc(), diag::err_attribute_address_space_negative)
+ << ASArgExpr->getSourceRange();
+ return;
+ }
+ addrSpace.setIsSigned(false);
+ }
+ llvm::APSInt max(addrSpace.getBitWidth());
+ max = QualType::MaxAddressSpace;
+ if (addrSpace > max) {
+ S.Diag(Attr.getLoc(), diag::err_attribute_address_space_too_high)
+ << QualType::MaxAddressSpace << ASArgExpr->getSourceRange();
+ return;
+ }
+
unsigned ASIdx = static_cast<unsigned>(addrSpace.getZExtValue());
Type = S.Context.getAddrSpaceQualType(Type, ASIdx);
}