[PATCH] D58060: Fix diagnostic for addr spaces in static_cast

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 13 09:54:39 PST 2019


Anastasia added a comment.

In D58060#1396416 <https://reviews.llvm.org/D58060#1396416>, @ebevhan wrote:

> So static_cast permits conversions from AS1 to AS2 where that conversion is implicitly allowed, and the new addrspace_cast would permit conversions from AS1 to AS2 where it is explicitly allowed. That seems like it fits in rather well with the idea in D57464 <https://reviews.llvm.org/D57464> regarding support for specifying permitted AS conversions in target.
>
> How about nested pointers, such as `__X int * *` -> `__Y int * *` or `__X int * __Y *` -> `int * __Y *`? static_cast has some ruleset for how to deal with qualifiers in nested pointers, I think, but I'm not sure how the rules for ASes should be here.


We had discussion related to this with John earlier. And I documented it in this bug: https://bugs.llvm.org/show_bug.cgi?id=39674

> There's also C-style casts. Will addrspace_cast be added to the C-style cast rules somewhere?
> 
> (I should probably have commented on the original RFC)

Yes, exactly. I am working on a patch now that separates the address space casting out into a function to be used in C-style cast only as a first step (because I would like to disallow accidental unsafe address space conversions in `reinterpret_cast`). Then we would just need to add parsing of a new cast operator and mapping into the new function.


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

https://reviews.llvm.org/D58060





More information about the cfe-commits mailing list