Added new diagnostics when templates are instantiated with different address space from the one provided in definition.
This also prevents deducing generic address space in pointer type of templates to allow giving them concrete address space.
Differential D55127
[OpenCL] Diagnose conflicting address spaces between template definition and its instantiation Anastasia on Nov 30 2018, 8:16 AM. Authored by
Details Added new diagnostics when templates are instantiated with different address space from the one provided in definition. This also prevents deducing generic address space in pointer type of templates to allow giving them concrete address space.
Diff Detail
Event Timeline
Comment Actions Okay. What you're saying is that the current OpenCL C++ compiler is implicitly adding an address-space qualifier at the top level to explicit template arguments. I agree that it should not be doing that. Can you explain why the changes to TreeTransform are required? Comment Actions
When address spaces of template parameter and argument are given explicitly they might mismatch. For example, foo1 (in the test) is instantiated with __local int but the template parameter of foo1 is __global T. Currently clang fails to compile this with ICE while rebuilding the type that has multiple inconsistent addr space qualifiers. My patch fixes it, by giving an error instead of attempting to rebuild the type, that the addr space qualifiers mismatch. There is another example of the same issue - foo3, but with non-pointer type. |
I think a better comment here would be something like "Don't deduce address spaces for dependent types because they might end up instantiating to a type with a different address space qualifier."