[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 22 02:38:48 PDT 2024


================
@@ -1426,6 +1727,34 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
   if (!AddedAny)
     Transform.buildSimpleDeductionGuide(std::nullopt);
 
+  // FIXME: Handle explicit deduction guides from inherited constructors
+  // when the base deduction guides are declared after this has first run
+  if (getLangOpts().CPlusPlus23 &&
+      Pattern->getTemplatedDecl()->hasDefinition()) {
+    unsigned BaseIdx = 0;
+    for (const auto &Base : Pattern->getTemplatedDecl()->bases()) {
+      ++BaseIdx;
+      if (!Base.getType()->isDependentType())
----------------
hokein wrote:

We will ignore the case like

```
template <typename T2> struct C : public B<int> {
  using B<T2>::B;
};
```

I couldn't find any word in the standard suggesting that this case should be filtered out, and gcc accepts it, https://godbolt.org/z/4e46Ecb1s.
 

https://github.com/llvm/llvm-project/pull/98788


More information about the cfe-commits mailing list