summaryrefslogtreecommitdiffstats
path: root/clang/lib
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
commit8945266f3d024d8b494c7751175519a723205e67 (patch)
tree18a4aee5cd819024c731d9cfa369e6612d5eaa75 /clang/lib
parentec5ae3d75ad35a62907d55924ad0d685377eb311 (diff)
downloadbcm5719-llvm-8945266f3d024d8b494c7751175519a723205e67.tar.gz
bcm5719-llvm-8945266f3d024d8b494c7751175519a723205e67.zip
Bounds checking for address spaces.
llvm-svn: 77303
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaType.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 226f2143918..d3daa07a9cc 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud