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
Hmm. So this method, confusingly, will not return true for a deduced auto, unless the deduced type is itself an undeduced auto (which I'm not sure can happen). I think it at least needs a different name; isUndeducedAutoType() would be okay if the latter case is not possible. But it might be better if we can just define away the need for the method entirely.