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
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 7cfbc7e..c6a8210 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1104,7 +1104,10 @@
   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 @@
                                  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