This is an archive of the discontinued LLVM Phabricator instance.

Fix undeduced type when instanciating template member
ClosedPublic

Authored by serge-sans-paille on Jun 7 2021, 3:23 PM.

Details

Summary

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 Timeline

serge-sans-paille requested review of this revision.Jun 7 2021, 3:23 PM
serge-sans-paille created this revision.
aaron.ballman added a subscriber: rsmith.

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
}

https://godbolt.org/z/KMeE9ssns

aaron.ballman edited subscribers, added: cfe-commits; removed: rsmith.Jun 8 2021, 10:48 AM

Adding the mailing lists to the review.

Added test + fix suggested by @aaron.ballman

I think this is reasonable, but I'd like to hear from @rsmith before landing this.

@rsmith : any opinion on that one?

aaron.ballman accepted this revision.Jun 21 2021, 9:58 AM

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.

This revision is now accepted and ready to land.Jun 21 2021, 9:58 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2021, 1:52 AM