]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: tweak deduction with auto template parms
authorJason Merrill <jason@redhat.com>
Thu, 23 Jun 2022 01:29:16 +0000 (21:29 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 23 Jun 2022 03:23:01 +0000 (23:23 -0400)
While looking at PR105964 I noticed that we were unnecessarily repeating
the deduction loop because of seeing a non-type parameter with type 'auto'.
It is indeed dependent, but not on any other deductions.

gcc/cp/ChangeLog:

* pt.cc (type_unification_real): An auto tparm can't
be affected by other deductions.

gcc/cp/pt.cc

index 4d1c325432d64297615cc78c9c2c97fa2f9db627..80d2bec23484c1b26cc28a1299c7d6b933954af4 100644 (file)
@@ -22982,6 +22982,7 @@ type_unification_real (tree tparms,
             deduced from a later argument than the one from which
             this parameter can be deduced.  */
          if (TREE_CODE (tparm) == PARM_DECL
+             && !is_auto (TREE_TYPE (tparm))
              && uses_template_parms (TREE_TYPE (tparm))
              && saw_undeduced < 2)
            {
@@ -23042,6 +23043,7 @@ type_unification_real (tree tparms,
 
          if (saw_undeduced == 1
              && TREE_CODE (parm) == PARM_DECL
+             && !is_auto (TREE_TYPE (parm))
              && uses_template_parms (TREE_TYPE (parm)))
            {
              /* The type of this non-type parameter depends on undeduced