[PATCH] D62584: [OpenCL][PR42033] Deducing addr space with template parameter types

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 11:02:55 PDT 2019


Anastasia marked an inline comment as done.
Anastasia added inline comments.


================
Comment at: lib/Sema/TreeTransform.h:5363
+    if (ResultType.getAddressSpace() != LangAS::Default &&
+        (ResultType.getAddressSpace() != LangAS::opencl_private)) {
       SemaRef.Diag(TL.getReturnLoc().getBeginLoc(),
----------------
I am trying to be a bit more helpful here although I am not sure if we should instead require explicit template parameter and fail the template deduction instead.

Basically, do we want the following code to always require specifying template argument explicitly:


```
template <class T>
T xxx(T *in) {
  T *i = in;
  return *i;
}

__kernel void test() {
  int foo[10];
  xxx<int>(&foo[0]); // if we deduce type from foo, it ends up being qualified by __private that we currently diagnose. However private is default (implicit) address space for return type so technically there is no danger in just allowing xxx(&foo[0])
}
```


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

https://reviews.llvm.org/D62584





More information about the cfe-commits mailing list