[PATCH] D98855: [OpenCL] Support template parameters for as_type

Sven van Haastregt via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 18 10:35:34 PDT 2021


svenvh added inline comments.
Herald added a subscriber: ldrumm.


================
Comment at: clang/test/SemaOpenCLCXX/template-astype.cl:5
+auto templated_astype(T x) {
+  return as_int2(x);
+  // expected-error at -1{{invalid reinterpretation: sizes of 'int2' (vector of 2 'int' values) and '__private int' must match}}
----------------
Anastasia wrote:
> could we also add another template with use of `__builtin_astype` directly?
> 
> In case we change as_type implementation one day the clang builtin will still be tested too. :)
Sure, I can add extend this test with the following before committing, if that is okay with you?

```// Test __builtin_astype.
template <typename T>
auto templated_builtin_astype(T x) {
  return __builtin_astype(x, int2);
}

auto test_builtin(char8 x) { return templated_builtin_astype(x); }```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98855



More information about the cfe-commits mailing list