This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Support for P0961R1: Relaxing the structured bindings customization point finding rules
ClosedPublic

Authored by erik.pilkington on Aug 7 2018, 4:34 PM.

Details

Summary

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0961r1.html

I don't believe an actual defect report was filed for this, but the paper (in the "wording" section) claims that we should back-port this to C++17 as if it were a defect report. Besides that, this is pretty straightforward.

Thanks for taking a look!
Erik

Diff Detail

Event Timeline

erik.pilkington created this revision.Aug 7 2018, 4:34 PM
rsmith added inline comments.Aug 7 2018, 4:48 PM
clang/lib/Sema/SemaDeclCXX.cpp
1118–1130

This should be done by walking the lookup results, not by filtering them. Testcase:

struct A {
  int get();
};
struct B {
  template<int> int get();
};
struct C : A, B {};
// plus specializations of tuple_size<C> and tuple_element<N, C>
auto [x] = C();

This should be ill-formed due to ambiguity when looking up C::get. We should not resolve the ambiguity by selecting B::get.

Address review comments.

clang/lib/Sema/SemaDeclCXX.cpp
1118–1130

Ah, I see. In the new patch we finish the class member access lookup, then we check this condition separately. I added this test to the patch. Thanks!

rsmith accepted this revision.Aug 9 2018, 12:24 PM

LGTM with a small bugfix.

clang/lib/Sema/SemaDeclCXX.cpp
1122

You should use D->getUnderlyingDecl() rather than just D here, otherwise you'll reject this:

struct A {
  template<int> void get();
};
struct B : A {
  using A::get;
};

... because D will be a UsingShadowDecl not a FunctionTemplateDecl. (Please also add a corresponding testcase.)

This revision is now accepted and ready to land.Aug 9 2018, 12:24 PM
This revision was automatically updated to reflect the committed changes.