diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-04-15 19:46:20 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-04-15 19:46:20 +0000 |
commit | 5666d36cce566b59be271670364794de9803af04 (patch) | |
tree | c9608a6a88a80fa8c0bfba433e3cb02977089b76 /lib | |
parent | 893e1cc13ab17e96ada5019df6978af1668fee26 (diff) |
Forbid the use of C++ new/delete to allocate/free objects within an
address space. I could see that this functionality would be useful,
but not in its current form (where the address space is ignored):
rather, we'd want to encode the address space into the parameter list
passed to operator new/operator delete somehow, which would require a
bunch more semantic analysis.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129593 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7cfbc7e172..c6a8210911 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1104,7 +1104,10 @@ bool Sema::CheckAllocatedType(QualType AllocType, SourceLocation Loc, else if (AllocType->isVariablyModifiedType()) return Diag(Loc, diag::err_variably_modified_new_type) << AllocType; - + else if (unsigned AddressSpace = AllocType.getAddressSpace()) + return Diag(Loc, diag::err_address_space_qualified_new) + << AllocType.getUnqualifiedType() << AddressSpace; + return false; } @@ -1725,7 +1728,10 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, PDiag(diag::warn_delete_incomplete) << Ex.get()->getSourceRange())) return ExprError(); - + else if (unsigned AddressSpace = Pointee.getAddressSpace()) + return Diag(Ex.get()->getLocStart(), + diag::err_address_space_qualified_delete) + << Pointee.getUnqualifiedType() << AddressSpace; // C++ [expr.delete]p2: // [Note: a pointer to a const type can be the operand of a // delete-expression; it is not necessary to cast away the constness |