+2008-01-15 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR c++/34052
+ * pt.c (check_default_tmpl_args): Check for parameter packs that
+ aren't at the end of a primary template.
+ (push_template_decl_real): Remove check for parameter packs that
+ aren't at the end of a primary template; that now happens in
+ check_default_tmpl_args.
+ * semantics.c (finish_template_template_parm): Use
+ check_default_tmpl_args to check for errors in the template
+ parameter list.
+
2008-01-12 Doug Kwan <dougkwan@google.com>
* decl.c: (grokdeclarator): Use OPT_Wignored_qualifiers
return decl;
}
-/* Check that a template declaration's use of default arguments is not
- invalid. Here, PARMS are the template parameters. IS_PRIMARY is
- nonzero if DECL is the thing declared by a primary template.
- IS_PARTIAL is nonzero if DECL is a partial specialization.
+/* Check that a template declaration's use of default arguments and
+ parameter packs is not invalid. Here, PARMS are the template
+ parameters. IS_PRIMARY is nonzero if DECL is the thing declared by
+ a primary template. IS_PARTIAL is nonzero if DECL is a partial
+ specialization.
IS_FRIEND_DECL is nonzero if DECL is a friend function template
TREE_PURPOSE (parm) = error_mark_node;
no_errors = false;
}
+ else if (is_primary
+ && !is_partial
+ && !is_friend_decl
+ && TREE_CODE (decl) == TYPE_DECL
+ && i < ntparms - 1
+ && template_parameter_pack_p (TREE_VALUE (parm)))
+ {
+ /* A primary class template can only have one
+ parameter pack, at the end of the template
+ parameter list. */
+
+ if (TREE_CODE (TREE_VALUE (parm)) == PARM_DECL)
+ error ("parameter pack %qE must be at the end of the"
+ " template parameter list", TREE_VALUE (parm));
+ else
+ error ("parameter pack %qT must be at the end of the"
+ " template parameter list",
+ TREE_TYPE (TREE_VALUE (parm)));
+
+ TREE_VALUE (TREE_VEC_ELT (inner_parms, i))
+ = error_mark_node;
+ no_errors = false;
+ }
}
}
}
if (is_partial)
return process_partial_specialization (decl);
- /* A primary class template can only have one parameter pack, at the
- end of the template parameter list. */
- if (primary && TREE_CODE (decl) == TYPE_DECL)
- {
- tree inner_parms
- = INNERMOST_TEMPLATE_PARMS (current_template_parms);
- int i, len = TREE_VEC_LENGTH (inner_parms);
- for (i = 0; i < len - 1; i++)
- {
- tree parm = TREE_VALUE (TREE_VEC_ELT (inner_parms, i));
-
- if (template_parameter_pack_p (parm))
- {
- if (TREE_CODE (parm) == PARM_DECL)
- error ("parameter pack %qE must be at the end of the"
- " template parameter list", parm);
- else
- error ("parameter pack %qT must be at the end of the"
- " template parameter list", TREE_TYPE (parm));
-
- TREE_VALUE (TREE_VEC_ELT (inner_parms, i)) = error_mark_node;
- }
- }
- }
-
args = current_template_args ();
if (!ctx