Basically, if the instantiation of a member variable makes it possible to compute a previously undeduced type, we should use that piece of information.
Should fix https://bugs.llvm.org/show_bug.cgi?id=50590
Differential D103849
Fix undeduced type when instanciating template member serge-sans-paille on Jun 7 2021, 3:23 PM. Authored by
Details
Basically, if the instantiation of a member variable makes it possible to compute a previously undeduced type, we should use that piece of information. Should fix https://bugs.llvm.org/show_bug.cgi?id=50590
Diff Detail
Event TimelineComment Actions I'm not 100% certain these changes are correct because template instantiation isn't always the easiest thing to reason about, so adding @rsmith for his expertise in the area. That said, if this change is along the lines of correct, I think a similar change is needed in MemberExpr::setMemberDecl() as well. There are some SemaCXX tests that we can add that this fixes as well. e.g., template <typename> struct pack { template <typename T> constexpr static auto some_boolean_cx_value = true; }; bool usage() { // Changing the return type here from `auto` to `bool` gives nonsense diagnostics in both the DeclRefExpr and MemberExpr cases return pack<char>{}.some_boolean_cx_value<int>; // This is the MemberExpr version of your test, which fails in Sema but not CodeGen } Comment Actions This LGTM as far as the fix seems like an improvement, though I'm not 100% certain that the fix is in the right place. Please give a few more days for @rsmith to consider the changes before landing, but if we don't hear from him by Fri (6/25), go ahead and land. |