]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: deducing empty type vs non-type argument pack
authorPatrick Palka <ppalka@redhat.com>
Wed, 19 Jul 2023 20:11:38 +0000 (16:11 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 19 Jul 2023 20:11:38 +0000 (16:11 -0400)
Within a template parameter list, a non-type template parameter pack is
represented as a PARM_DECL.  But in a couple of spots where we need to
deduce and create an empty argument pack, we test for TEMPLATE_PARM_INDEX
(within a template parameter list) instead of for PARM_DECL, and so we
end up creating a TYPE_ARGUMENT_PACK even in the non-type case.  This
patch fixes this (seemingly harmless) bug.

gcc/cp/ChangeLog:

* pt.cc (type_unification_real): Test for PARM_DECL instead
of TEMPLATE_PARM_INDEX to distinguish a type vs non-type
template parameter pack.
(type_targs_deducible_from): Likewise.

gcc/cp/pt.cc

index d882e9dd1178aab29b354ad3022e18a5c6ead385..21b08a6266a57268e5d1eb13c6798697467e133e 100644 (file)
@@ -23367,7 +23367,7 @@ type_unification_real (tree tparms,
            {
              tree arg;
 
-             if (TREE_CODE (tparm) == TEMPLATE_PARM_INDEX)
+             if (TREE_CODE (tparm) == PARM_DECL)
                {
                  arg = make_node (NONTYPE_ARGUMENT_PACK);
                  TREE_CONSTANT (arg) = 1;
@@ -30398,7 +30398,7 @@ type_targs_deducible_from (tree tmpl, tree type)
        if (template_parameter_pack_p (tparm))
          {
            tree arg;
-           if (TREE_CODE (tparm) == TEMPLATE_PARM_INDEX)
+           if (TREE_CODE (tparm) == PARM_DECL)
              {
                arg = make_node (NONTYPE_ARGUMENT_PACK);
                TREE_CONSTANT (arg) = 1;