[OpenCL] Improve diagnostic for placement new
Without an explicit declaration for placement new, clang would reject
uses of placement new with "'default new' is not supported in OpenCL
C++". This may mislead users into thinking that placement new is not
supported, see e.g. PR42060.
Clarify that placement new requires an explicit declaration.
Differential Revision: https://reviews.llvm.org/D63561
llvm-svn: 364423
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index b59f3fa..32b35ba 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2413,7 +2413,11 @@
}
if (getLangOpts().OpenCLCPlusPlus && R.empty()) {
- Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+ if (PlaceArgs.empty()) {
+ Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+ } else {
+ Diag(StartLoc, diag::err_openclcxx_placement_new);
+ }
return true;
}