[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 11 09:50:12 PST 2020


tra added a comment.

In D91088#2388496 <https://reviews.llvm.org/D91088#2388496>, @yaxunl wrote:

> added diagnosing referencing host variable in device functions

Thank you for fixing this. The new changes look good, but I think they should be in a separate patch.



================
Comment at: clang/lib/Sema/SemaExpr.cpp:357
 
+  if (LangOpts.CUDAIsDevice) {
+    auto *FD = dyn_cast_or_null<FunctionDecl>(CurContext);
----------------
This could use a comment about why we only check `D->H` references.
`H->D` references will still work (sort of) because on the host side we have matching `shadow` variables.




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

https://reviews.llvm.org/D91088



More information about the cfe-commits mailing list