Desugar TemplateSpecializationType if any of the template arguments is a decltype.
'aka Foo<int>' is much better than 'Foo<decltype(arbitrary expression of type int)>' :)
Differential D3588
PR10405 Missing actual type (aka) in error message when using decltype as a template parameter nikola on May 1 2014, 7:05 PM. Authored by
Details
Desugar TemplateSpecializationType if any of the template arguments is a decltype. 'aka Foo<int>' is much better than 'Foo<decltype(arbitrary expression of type int)>' :)
Diff Detail Event TimelineComment Actions This seems like a very special case; I wonder if there's some more general rule we should be using here. (Perhaps we should provide an 'aka' if there's a decltype anywhere in the type?) In any case, the same rule should also apply to GNU __typeof. Comment Actions What cases would we need to handle to make this more generic? I'm thinking FunctionType (return type and parameters) and Template specialization (but at arbitrary nesting level, vector<vector<decltype(something)>>). Have I missed any (plain arrays), and more importantly is there a way to get this info at the moment? Comment Actions I think the best approach for a template specialization type would probably be to walk the explicitly-specified template arguments, and desugar each one as if it were a top-level type. If you desugar any, rebuild the template specialization type with the desugared type. Doing the same thing for the parameter and return types of function types might also make some sense. Comment Actions In what situation would FunctionType show up? In this case x is a PointerType which is not sugared. int (*x)(); Comment Actions Here's one way to get a diagnostic with a FunctionType in it: void (&f)(decltype(1+1)) = 0; This gives:
Comment Actions It's been some time since we looked at this. I'm having issues addressing your last comment, non type template parameters. What's the idea here, to turn A<1+2> into A<int>? While tinkering with this I managed to produce desugar A<1+2> as A<3> by accident so I'm not really sure what you meant. I was surprised to see that both A<1> and A<1+2> have a TemplateArgument with Expression kind. Having 'aka A<int>' for each A<1> seems too spammy but I couldn't figure out how to differentiate them. |
Better would be something like "Desugar template specializations if any template argument should be desugared."