[PATCH] D128276: clang: perform deduction at the right depth on Sema::AddMethodTemplateCandidate

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 17 18:51:27 PDT 2022


mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 445370.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128276/new/

https://reviews.llvm.org/D128276

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp


Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp
===================================================================
--- /dev/null
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5-cxx20.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+namespace pr28087 {
+template <typename F> auto apply(F f) { f(); }
+template <class...> struct S {
+  template <int> auto f(decltype(apply([](auto...) {})));
+};
+template struct S<>;
+} // namespace pr28087
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -7084,7 +7084,8 @@
   //   functions. In such a case, the candidate functions generated from each
   //   function template are combined with the set of non-template candidate
   //   functions.
-  TemplateDeductionInfo Info(CandidateSet.getLocation());
+  TemplateDeductionInfo Info(CandidateSet.getLocation(),
+                             MethodTmpl->getTemplateParameters()->getDepth());
   FunctionDecl *Specialization = nullptr;
   ConversionSequenceList Conversions;
   if (TemplateDeductionResult Result = DeduceTemplateArguments(
@@ -14171,8 +14172,12 @@
       IsError |= InputInit.isInvalid();
       Arg = InputInit.getAs<Expr>();
     } else {
-      ExprResult DefArg =
-          S.BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));
+      ParmVarDecl *Param = Method->getParamDecl(i);
+      if (!Param->hasDefaultArg()) {
+        IsError = true;
+        break;
+      }
+      ExprResult DefArg = S.BuildCXXDefaultArgExpr(LParenLoc, Method, Param);
       if (DefArg.isInvalid()) {
         IsError = true;
         break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128276.445370.patch
Type: text/x-patch
Size: 1763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220718/6b7a0a75/attachment-0001.bin>


More information about the cfe-commits mailing list