[PATCH] D52598: [OpenCL] Fixed address space cast in C style cast of C++ parsing

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 27 04:03:41 PDT 2018


Anastasia created this revision.
Anastasia added reviewers: rjmccall, yaxunl.

C style cast in OpenCL C++ was ignoring the address space conversions from OpenCL C and as a result accepting incorrect code to compile. This commit adds correctness checking for address spaces. This makes all OpenCL C address space conversion tests from Sema passing in `-cl-std=c++` mode too. Error messages have to be changed to C++ style in multiple places, but semantics of the diagnostics stay the same.

**Note:** this doesn't fix C++ cast operators. OpenCL C++ s3.4.4 defines special address space cast operators that align with C++'s philosophy of safe casts. The motivation behind this is that address space casts might require address translation (denoted by the `addrspacecast` IR instruction). In order to avoid operations modifying the type or constness together with translation of addresses, a separate cast operator is introduced. We might still have to fix the semantics of address spaces in `static_cast`, `reinterpret_cast` and `const_cast` but it's currently unclear to me. I will address this as a separate patch.


https://reviews.llvm.org/D52598

Files:
  lib/Sema/SemaCast.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52598.167268.patch
Type: text/x-patch
Size: 32361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180927/fd55ea90/attachment-0001.bin>


More information about the cfe-commits mailing list