[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 18 05:14:08 PST 2019


Anastasia created this revision.
Anastasia added reviewers: rjmccall, ebevhan.
Herald added a subscriber: jdoerfert.

This patch adds a new diagnostic for mismatching address spaces to be used for C++ casts (TODO: only enabled in C style cast for now, the rest will follow!).

This change extends C-style cast rules to account for address spaces. It also adds a separate function for address space cast checking that can be used to map from a separate address space cast operator `addrspace_cast` (to be added as a follow up patch).

Note, that after this change clang will no longer allows arbitrary address space conversions in `reinterpret_casts` because they can lead to accidental errors. The implicit safe conversions would still be allowed.

See RFC for more details: http://lists.llvm.org/pipermail/cfe-dev/2018-December/060546.html


https://reviews.llvm.org/D58346

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/SemaCXX/address-space-conversion.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58346.187227.patch
Type: text/x-patch
Size: 21192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190218/6c645a5d/attachment-0001.bin>


More information about the cfe-commits mailing list