================
@@ -11757,6 +11791,42 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl 
*Found, Decl *Templated,
       return;
     }
 
+    // Errors in deduction guides from inherited constructors
+    // will manifest as substitution failures in the return type
+    // partial specialization, so we show a generic diagnostic
+    // in this case.
+    if (auto *DG = dyn_cast<CXXDeductionGuideDecl>(Templated);
+        DG && DG->getSourceDeductionGuideKind() ==
+                  CXXDeductionGuideDecl::SourceDeductionGuideKind::
+                      InheritedConstructor) {
+      CXXDeductionGuideDecl *Source = DG->getSourceDeductionGuide();
+      assert(Source &&
+             "Inherited constructor deduction guides must have a source");
+
+      auto GetDGDeducedTemplateType =
+          [](CXXDeductionGuideDecl *DG) -> QualType {
+        return QualType(cast<ClassTemplateDecl>(DG->getDeducedTemplate())
+                            ->getTemplatedDecl()
+                            ->getTypeForDecl(),
+                        0);
+      };
+
+      QualType DeducedRecordType = GetDGDeducedTemplateType(DG);
+      QualType InheritedRecordType = GetDGDeducedTemplateType(Source);
+      S.Diag(Templated->getLocation(),
+             diag::note_ovl_candidate_inherited_constructor_deduction_failure)
+          << DeducedRecordType << InheritedRecordType << TemplateArgString;
+
+      CXXConstructorDecl *Ctor = DG->getCorrespondingConstructor();
+      if (Ctor)
+        S.Diag(
+            Ctor->getBeginLoc(),
+            diag::
+                
note_ovl_candidate_inherited_constructor_deduction_failure_source)
+            << InheritedRecordType;
+      return;
----------------
antangelo wrote:

I'm using the source location of the inherited constructor deduction guide to 
store the location of the using decl that inherits the base constructors (as it 
is otherwise difficult to pass this information around), so the notes for 
deduction guide failure will point there instead of at the source constructor 
(or deduction guide in the explicit case).

I have added additional diagnostics that print the source deduction guide 
declaration (with the source deduction guide's location) for both implicit and 
explicit guides when we note the deduction guide declarations for implicit 
guides as a workaround, which also removes the need for the above note by 
extension.

https://github.com/llvm/llvm-project/pull/98788
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to