(cp_parser *, tree, tree, tree);
static void cp_parser_late_parsing_nsdmi
(cp_parser *, tree);
+static bool cp_parser_early_parsing_nsdmi
+ (cp_parser *, tree);
static void cp_parser_late_parsing_default_args
(cp_parser *, tree);
static tree cp_parser_sizeof_operand
if (DECL_DECLARES_FUNCTION_P (decl))
cp_parser_save_default_args (parser, STRIP_TEMPLATE (decl));
else if (TREE_CODE (decl) == FIELD_DECL
- && DECL_INITIAL (decl))
+ && DECL_INITIAL (decl)
+ && !cp_parser_early_parsing_nsdmi (parser, decl))
/* Add DECL to the queue of NSDMI to be parsed later. */
vec_safe_push (unparsed_nsdmis, decl);
}
DECL_INITIAL (field) = def;
}
+/* If the DEFERRED_PARSE for FIELD is safe to parse immediately, do so.
+ Returns true if deferred parsing is no longer needed. */
+
+static bool
+cp_parser_early_parsing_nsdmi (cp_parser *parser, tree field)
+{
+ tree init = DECL_INITIAL (field);
+ if (TREE_CODE (init) != DEFERRED_PARSE)
+ return true;
+
+ cp_token_cache *tokens = DEFPARSE_TOKENS (init);
+ for (cp_token *p = tokens->first; p != tokens->last; ++p)
+ if (p->type == CPP_NAME
+ || p->keyword == RID_THIS
+ || p->keyword == RID_OPERATOR)
+ /* There's a name to look up or 'this', give up. */
+ return false;
+
+ /* It's trivial, parse now. */
+ cp_parser_late_parsing_nsdmi (parser, field);
+ return true;
+}
+
/* FN is a FUNCTION_DECL which may contains a parameter with an
unparsed DEFERRED_PARSE. Parse the default args now. This function
assumes that the current scope is the scope in which the default