]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: alias_ctad_tweaks ICE w/ inherited CTAD [PR119687]
authorPatrick Palka <ppalka@redhat.com>
Thu, 10 Apr 2025 19:49:12 +0000 (15:49 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 10 Apr 2025 19:49:12 +0000 (15:49 -0400)
With inherited CTAD the set of guides may be a two-dimensional overload
set (i.e. OVERLOADs of OVERLOADs) so alias_ctad_tweaks (which also does
the inherited CTAD transformation) needs to use the 2D-aware lkp_iterator
instead of ovl_iterator, or better yet use the more idiomatic lkp_range.

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.

Reviewed-by: Jason Merill <jason@redhat.com>
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp23/class-deduction-inherited8.C [new file with mode: 0644]

index 63c2ec0c59b33d3cc39aaaa081cceeda1e51ce1b..805b274069bf0d9b847cdd50bfe10beffa18af76 100644 (file)
@@ -30936,9 +30936,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 (file)
index 0000000..4494c70
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/119687
+// { dg-do compile { target c++17 } }
+
+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{}};
+}