On 4/9/25 11:11 AM, Patrick Palka wrote:
Bootstrap and regtest running on x86_64-pc-linux-gnu, does this look OK for trunk/14 if successful?
OK.
On a similar note, as a small optimization in deduction_guides_for I think we can replace the lookup_add loop with a single call to lookup_add, but I'll leave that for GCC 16. -- >8 -- With inherited CTAD the set of guides may be a two-dimensional overload set (i.e. OVERLOADs containing OVERLOADs) so alias_ctad_tweaks (which also handles the inherited CTAD transformation) needs to use the 2D-aware lkp_iterator instead of ovl_iterator. Actually, we might as well use the more idiomatic lkp_range here. PR c++/119687 gcc/cp/ChangeLog: * pt.cc (alias_ctad_tweaks): Use lkp_range / lkp_iterator instead of ovl_iterator. gcc/testsuite/ChangeLog: * g++.dg/cpp23/class-deduction-inherited8.C: New test. --- gcc/cp/pt.cc | 3 +-- .../g++.dg/cpp23/class-deduction-inherited8.C | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ffd23d9cd13b..c73db02e42e1 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30922,9 +30922,8 @@ alias_ctad_tweaks (tree tmpl, tree uguides) tree aguides = NULL_TREE; tree atparms = INNERMOST_TEMPLATE_PARMS (fullatparms); unsigned natparms = TREE_VEC_LENGTH (atparms); - for (ovl_iterator iter (uguides); iter; ++iter) + for (tree f : lkp_range (uguides)) { - tree f = *iter; tree in_decl = f; location_t loc = DECL_SOURCE_LOCATION (f); tree ret = TREE_TYPE (TREE_TYPE (f)); diff --git a/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C b/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C new file mode 100644 index 000000000000..79fceadd9e1c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C @@ -0,0 +1,21 @@ +// PR c++/119687 +// { dg-do compile { target c++20 } } + +template <typename> class QFlagsStorage{}; + +template <typename Enum> struct QFlagsStorageHelper : QFlagsStorage<Enum> { + using QFlagsStorage<Enum>::QFlagsStorage; + +public: + QFlagsStorageHelper(Enum); +}; + +template <typename Enum> struct QFlags : public QFlagsStorageHelper<Enum> { + using Base = QFlagsStorageHelper<Enum>; + using Base::Base; + QFlags(Enum); +}; + +void f(int flag) { + QFlags{int{}}; +}