A regression was introduced in D64400 because auto is using the same logic as templates. However, deduction of addr spaces wasn't working correctly even before.
Here are the rules that are implemented in this patch:
- For non-reference and non-pointer types deduction can be done early because addr space is not going to be taken from init expr
- For ref or ptr auto types we should prevent deducing addr space before the deduction of the whole type (incl its pointee addr spaces) from init expr
Okay, I understand why you're doing this now, and it makes sense. I would like to propose changing the entire way deduceOpenCLImplicitAddrSpace works. Why don't we do it more like how ObjC ARC infers its implicit ownership qualifiers:
Then all of this context-specific logic where we're looking at different declarator chunks and trying to infer the relationship of the current chunk to the overall type being parsed can just go away or get pushed into a more appropriate position.