[PATCH] D63561: [OpenCL] Improve diagnostic for placement new

Sven van Haastregt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 06:33:51 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL364423: [OpenCL] Improve diagnostic for placement new (authored by svenvh, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63561?vs=205611&id=206650#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63561/new/

https://reviews.llvm.org/D63561

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaOpenCLCXX/newdelete.cl


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/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;
     }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8809,6 +8809,9 @@
   "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">,
Index: cfe/trunk/test/SemaOpenCLCXX/newdelete.cl
===================================================================
--- cfe/trunk/test/SemaOpenCLCXX/newdelete.cl
+++ cfe/trunk/test/SemaOpenCLCXX/newdelete.cl
@@ -21,7 +21,7 @@
 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 at +1 {{candidate function not viable: requires 2 arguments, but 1 was provided}}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63561.206650.patch
Type: text/x-patch
Size: 1993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190626/ba45c650/attachment.bin>


More information about the llvm-commits mailing list