[PATCH] D101519: [C++4OpenCL] Fix reinterpret_cast of vectors and types with address spaces

Ole Strohm via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 29 04:14:13 PDT 2021


olestrohm created this revision.
olestrohm added reviewers: Anastasia, svenvh.
olestrohm added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
olestrohm requested review of this revision.
Herald added a subscriber: cfe-commits.

This fixes two issues with reinterpret_cast in C++ for OpenCL and adds tests to make sure they both pass without errors, and generate the correct code.

Reinterpret_cast can only convert a type to itself if it is an integral type (or pointer or reference or vectors), so I didn't include any exceptions for opencl types.
Not even float can be converted to itself, so I don't think it makes sense to allow this for any opencl types unlesss you think some of them fit the integral restriction.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=47977 and https://bugs.llvm.org/show_bug.cgi?id=49221


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101519

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
  clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101519.341460.patch
Type: text/x-patch
Size: 5320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210429/638393a9/attachment-0001.bin>


More information about the cfe-commits mailing list