This patch is fixing the issue reported in:
http://lists.llvm.org/pipermail/cfe-dev/2020-January/064273.html
and in the bug:
https://bugs.llvm.org/show_bug.cgi?id=39674
Since address space conversion changes pointer representation it is not legal to do it for the nested pointers even with compatible address spaces. Because the address space conversion in the nested levels can't be generated. The behavior implemented by this patch is as follows:
- Reject any implicit conversions of nested pointers with address spaces.
- Reject address space of nested pointers conversions in safe casts e.g. const_cast or static_cast.
- Allow conversion in low level C-style or reinterpret_cast but with a warning (this aligns with OpenCL C behavior).
Can we specialize the diagnostic here so that we get the good diagnostic in both language modes?