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

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 7 17:21:47 PDT 2018


erik.pilkington added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1118-1130
+    //   ... and if that finds at least one declaration that is a function
+    //   template whose first template parameter is a non-type parameter ...
+    LookupResult::Filter Filter = MemberGet.makeFilter();
+    while (Filter.hasNext()) {
+      NamedDecl *ND = Filter.next();
+      if (auto *FTD = dyn_cast<FunctionTemplateDecl>(ND)) {
+        TemplateParameterList *TPL = FTD->getTemplateParameters();
----------------
rsmith wrote:
> 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`.
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!


https://reviews.llvm.org/D50418





More information about the cfe-commits mailing list