[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
This commit is contained in:
parent
1a3dc76186
commit
1006a068c6
|
@ -8809,6 +8809,9 @@ def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
|
|||
"vector component name '%0' is an OpenCL version 2.2 feature">,
|
||||
InGroup<OpenCLUnsupportedRGBA>;
|
||||
|
||||
def err_openclcxx_placement_new : Error<
|
||||
"use of placement new requires explicit declaration">;
|
||||
|
||||
// MIG routine annotations.
|
||||
def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
|
||||
"'mig_server_routine' attribute only applies to routines that return a kern_return_t">,
|
||||
|
|
|
@ -2413,7 +2413,11 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class B {
|
|||
void test_default_new_delete(void *buffer, A **pa) {
|
||||
A *a = new A; // expected-error {{'default new' is not supported in OpenCL C++}}
|
||||
delete a; // expected-error {{'default delete' is not supported in OpenCL C++}}
|
||||
*pa = new (buffer) A; // expected-error {{'default new' is not supported in OpenCL C++}}
|
||||
*pa = new (buffer) A; // expected-error {{use of placement new requires explicit declaration}}
|
||||
}
|
||||
|
||||
// expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
|
||||
|
|
Loading…
Reference in New Issue