[PATCH] D102248: [C++4OpenCL] Fix initialization of __constant constructors without arguments

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 12 05:11:52 PDT 2021


Anastasia added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:12643
+      if (CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
+        for (auto *ctor : RD->ctors()) {
+          if (ctor->isConstexpr() && ctor->getNumParams() == 0 &&
----------------
ctor -> Ctor


================
Comment at: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp:20
+kernel void k() {
+  __constant X cx1;
+  __constant X cx2(1);
----------------
Btw, even though your change doesn't modify this I would suggest to add a CodeGen test that checks the initialization of objects in IR is adequate.


================
Comment at: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp:36
+  Z() __local = default;
+  Z() __global = default;
+  constexpr Z() __constant : z(0) {}
----------------
We seem to be missing the coverage with __constant and `= default`.


================
Comment at: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp:42
+  int w;
+  constexpr W() __constant = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
+};
----------------
I find the wording of the error a bit odd, but it is standard C++ though... 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102248



More information about the cfe-commits mailing list