[PATCH] D95840: [CUDA][HIP] Fix checking dependent initalizer

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 2 11:24:37 PST 2021


tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/Sema/SemaCUDA.cpp:538
       AllowedInit =
-          ((VD->getType()->isDependentType() || Init->isValueDependent()) &&
-           VD->isConstexpr()) ||
+          (VD->getType()->isDependentType() || Init->isValueDependent()) ||
           Init->isConstantInitializer(Context,
----------------
Nit, no need for `()` any more, as all parts of the expression ar `||`-ed together.


================
Comment at: clang/test/SemaCUDA/dependent-device-var.cu:8
+__device__ int fun1(T x) {
+  static __device__ int a = sizeof(x);
+  static __device__ int b = x;
----------------
So, the patch now allows using type-dependent constant expressions now. 
I'd add a comment highlighting this. It's not always obvious that the test's purpose is to verify the absence of an error.


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

https://reviews.llvm.org/D95840



More information about the cfe-commits mailing list