tree old_pack = TREE_VALUE (pack);
tree new_args = TREE_TYPE (pack);
int i, len = TREE_VEC_LENGTH (new_args);
+ int idx, level;
bool nondeduced_p = false;
+ /* By default keep the original deduced argument pack.
+ If necessary, more specific code is going to update the
+ resulting deduced argument later down in this function. */
+ template_parm_level_and_index (TREE_PURPOSE (pack), &level, &idx);
+ TMPL_ARG (targs, level, idx) = old_pack;
+
/* If NEW_ARGS contains any NULL_TREE entries, we didn't
actually deduce anything. */
for (i = 0; i < len && !nondeduced_p; ++i)
if (!old_pack)
{
tree result;
- int idx, level;
-
- template_parm_level_and_index (TREE_PURPOSE (pack), &level, &idx);
-
/* Build the deduced *_ARGUMENT_PACK. */
if (TREE_CODE (TREE_PURPOSE (pack)) == TEMPLATE_PARM_INDEX)
{
{
/* We only had the explicitly-provided arguments before, but
now we have a complete set of arguments. */
- int idx, level;
tree explicit_args = ARGUMENT_PACK_EXPLICIT_ARGS (old_pack);
- template_parm_level_and_index (TREE_PURPOSE (pack), &level, &idx);
-
- /* Keep the original deduced argument pack. */
- TMPL_ARG (targs, level, idx) = old_pack;
SET_ARGUMENT_PACK_ARGS (old_pack, new_args);
ARGUMENT_PACK_INCOMPLETE_P (old_pack) = 1;
new_args))
/* Inconsistent unification of this parameter pack. */
return 1;
- else
- {
- int idx, level;
-
- template_parm_level_and_index (TREE_PURPOSE (pack), &level, &idx);
-
- /* Keep the original deduced argument pack. */
- TMPL_ARG (targs, level, idx) = old_pack;
- }
}
return 0;
--- /dev/null
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR c++/40155
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+
+template <typename T> struct identity
+{ typedef T type; };
+
+template <typename RT, typename... A>
+int forward_call(RT (*) (A...), typename identity<A>::type...);
+
+int g (double);
+
+int i = forward_call(&g, 0);