+2013-11-14 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/57887
+ * parser.c (cp_parser_late_parsing_nsdmi): Call
+ maybe_begin_member_template_processing.
+ * pt.c (maybe_begin_member_template_processing): Handle NSDMIs.
+ (inline_needs_template_parms): Adjust.
+
2013-11-14 Andrew MacLeod <amacleod@redhat.com>
* class.c: Include only gimplify.h and gimple.h as needed.
{
tree def;
+ maybe_begin_member_template_processing (field);
+
push_unparsed_function_queues (parser);
def = cp_parser_late_parse_one_default_arg (parser, field,
DECL_INITIAL (field),
NULL_TREE);
pop_unparsed_function_queues (parser);
+ maybe_end_member_template_processing ();
+
DECL_INITIAL (field) = def;
}
struct pointer_set_t*, bool);
static tree expand_template_argument_pack (tree);
static tree build_template_parm_index (int, int, int, tree, tree);
-static bool inline_needs_template_parms (tree);
+static bool inline_needs_template_parms (tree, bool);
static void push_inline_template_parms_recursive (tree, int);
static tree retrieve_local_specialization (tree);
static void register_local_specialization (tree, tree);
Returns true if processing DECL needs us to push template parms. */
static bool
-inline_needs_template_parms (tree decl)
+inline_needs_template_parms (tree decl, bool nsdmi)
{
- if (! DECL_TEMPLATE_INFO (decl))
+ if (!decl || (!nsdmi && ! DECL_TEMPLATE_INFO (decl)))
return false;
return (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (most_general_template (decl)))
}
}
-/* Restore the template parameter context for a member template or
- a friend template defined in a class definition. */
+/* Restore the template parameter context for a member template, a
+ friend template defined in a class definition, or a non-template
+ member of template class. */
void
maybe_begin_member_template_processing (tree decl)
{
tree parms;
int levels = 0;
+ bool nsdmi = TREE_CODE (decl) == FIELD_DECL;
- if (inline_needs_template_parms (decl))
+ if (nsdmi)
+ decl = (CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl))
+ ? CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (decl))
+ : NULL_TREE);
+
+ if (inline_needs_template_parms (decl, nsdmi))
{
parms = DECL_TEMPLATE_PARMS (most_general_template (decl));
levels = TMPL_PARMS_DEPTH (parms) - processing_template_decl;