[PATCH] D67730: [CUDA][HIP] Fix typo in `BestViableFunction`

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 15:38:29 PDT 2019


tra added a comment.

LGTM. You may want to wait a bit for Justin's feedback, in case he has some concerns.



================
Comment at: clang/test/SemaCUDA/function-overload.cu:406
+
+// Two irrelevant classes with `operator-` defined. One of them is device only.
+struct C1 { int m; };
----------------
I'd remove `irrelevant`.


================
Comment at: clang/test/SemaCUDA/function-overload.cu:407-411
+struct C1 { int m; };
+struct C2 { int *m; };
+__device__
+int operator-(const C1 &x, const C1 &y) { return x.m - y.m; }
+int operator-(const C2 &x, const C2 &y) { return x.m - y.m; }
----------------
We don't need definitions for `struct` and `operator-`;

This should do:
```
struct C1;
struct C2;
__device__ int operator-(const C1 &x, const C1 &y);
int operator-(const C2 &x, const C2 &y);
...
int test_constexpr_overload(C2 &x, C2 &y) {
    return constexpr_overload(x, y);
}
```



================
Comment at: clang/test/SemaCUDA/function-overload.cu:414
+template <typename T>
+constexpr int constexpr_overload(const T &x, const T &y) {
+  return x - y;
----------------
Is `constexpr` necessary here? If not, then we would not need -std=c++11 either.
I think you really want `__host__ __device__` here instead. `constexpr` is just applying the attributes implicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67730





More information about the cfe-commits mailing list