On 12/12/2012 08:01 AM, Dodji Seketeli wrote:
Jason Merrill <ja...@redhat.com> writes:
I'd also like to move the scan and PACK_EXPANSION_EXTRA_ARGS code back
out of the loop.

Like this?

Let's put this scanning back in the loop over the packs that we already have in the main function.

+         if (argument_pack_element_is_expansion_p (arg, i))
+           {
+             has_expansion_arg = true;
+             if (TREE_CODE (parm) == PARM_DECL)
+               parm = DECL_INITIAL (parm);
+
+             int level = 0, idx = 0;
+             template_parm_level_and_index (parm, &level, &idx);
+
+             if (*fake_arg_level_to_prune == 0
+                 || *fake_arg_level_to_prune > level)
+               *fake_arg_level_to_prune = level;
+           }

This is now assuming that any expansion we see is a fake arg, which isn't the case for the testcase in this PR. Do we really need to recognize fake args rather than treating them the same as real args?

+      /* If one pack has an empty argument and another other doesn't,
+        or if for a given index one parameter pack has an expansion
+        as argument and another one doesn't, then

This seems to assume that any expansions in different argument packs will end up expanding to the same number of elements. I'm not sure that's a valid assumption; I think once we see an expansion, any non-expansion arguments after that index are also problematic.

+  /* If we have empty arguments ... */
+  if (has_empty_args)
+    /* ... we just return a pack expansion which pattern is PATTERN
+       into which ARGS has been substituted.  */;

I want to still handle this before the elements loop, too.

Jason

Reply via email to