+2019-06-23 Marek Polacek <polacek@redhat.com>
+
+ * call.c (convert_default_arg): Use DEFERRED_PARSE instead of
+ DEFAULT_ARG.
+ * cp-objcp-common.c (cp_tree_size): Likewise. Use tree_deferred_parse
+ instead of tree_default_arg.
+ * cp-tree.def: Rename DEFAULT_ARG to DEFERRED_PARSE.
+ * cp-tree.h: Rename DEFARG_TOKENS to DEFPARSE_TOKENS. Rename
+ DEFARG_INSTANTIATIONS to DEFPARSE_INSTANTIATIONS. Rename
+ tree_default_arg to tree_deferred_parse.
+ (UNPARSED_NOEXCEPT_SPEC_P): Use DEFERRED_PARSE instead of DEFAULT_ARG.
+ (cp_tree_node_structure_enum): Rename TS_CP_DEFAULT_ARG to
+ TS_CP_DEFERRED_PARSE.
+ (lang_tree_node): Rename tree_default_arg to tree_deferred_parse.
+ Rename default_arg to deferred_parse. Use TS_CP_DEFERRED_PARSE instead
+ of TS_CP_DEFAULT_ARG.
+ (defarg_location): Remove declaration.
+ (defparse_location): Add declaration.
+ * decl.c (grokfndecl): Use DEFERRED_PARSE instead of DEFAULT_ARG.
+ Call defparse_location instead of defarg_location.
+ (check_default_argument): Use DEFERRED_PARSE instead of DEFAULT_ARG.
+ (cp_tree_node_structure): Likewise. Use TS_CP_DEFERRED_PARSE instead
+ of TS_CP_DEFAULT_ARG.
+ * decl2.c (grokfield): Use DEFERRED_PARSE instead of DEFAULT_ARG.
+ * error.c (dump_expr): Likewise.
+ (location_of): Likewise.
+ * init.c (get_nsdmi): Likewise.
+ * parser.c (cp_parser_save_noexcept): Likewise. Use DEFPARSE_TOKENS
+ instead of DEFARG_TOKENS.
+ (cp_parser_late_noexcept_specifier): Likewise.
+ (cp_parser_late_parse_one_default_arg): Use DEFPARSE_TOKENS instead
+ of DEFARG_TOKENS.
+ (cp_parser_late_parsing_default_args): Use DEFERRED_PARSE instead of
+ DEFAULT_ARG. Use DEFPARSE_INSTANTIATIONS instead of
+ DEFARG_INSTANTIATIONS.
+ (cp_parser_cache_defarg): Use DEFERRED_PARSE instead of DEFAULT_ARG.
+ Use DEFPARSE_TOKENS instead of DEFARG_TOKENS. Use
+ DEFPARSE_INSTANTIATIONS instead of DEFARG_INSTANTIATIONS.
+ (defparse_location): Renamed from defarg_location.
+ * pt.c (tsubst_default_argument): Use DEFERRED_PARSE instead of
+ DEFAULT_ARG.
+ (tsubst_arg_types): Likewise.
+ (dependent_type_p_r): Likewise.
+ * tree.c (cp_tree_equal): Likewise.
+ (cp_walk_subtrees): Likewise.
+ * typeck.c (convert_arguments): Likewise.
+
2019-06-22 Marek Polacek <polacek@redhat.com>
PR c++/86476 - noexcept-specifier is a complete-class context.
/* If the ARG is an unparsed default argument expression, the
conversion cannot be performed. */
- if (TREE_CODE (arg) == DEFAULT_ARG)
+ if (TREE_CODE (arg) == DEFERRED_PARSE)
{
if (complain & tf_error)
error ("call to %qD uses the default argument for parameter %P, which "
case PTRMEM_CST: return sizeof (ptrmem_cst);
case BASELINK: return sizeof (tree_baselink);
case TEMPLATE_PARM_INDEX: return sizeof (template_parm_index);
- case DEFAULT_ARG: return sizeof (tree_default_arg);
+ case DEFERRED_PARSE: return sizeof (tree_deferred_parse);
case DEFERRED_NOEXCEPT: return sizeof (tree_deferred_noexcept);
case OVERLOAD: return sizeof (tree_overload);
case STATIC_ASSERT: return sizeof (tree_static_assert);
/* A using directive. The operand is USING_STMT_NAMESPACE. */
DEFTREECODE (USING_STMT, "using_stmt", tcc_statement, 1)
-/* An un-parsed default argument. Holds a vector of input tokens and
+/* An un-parsed operand. Holds a vector of input tokens and
a vector of places where the argument was instantiated before
- parsing had occurred. This is also used for delayed NSDMIs and
- noexcept-specifier parsing. */
-DEFTREECODE (DEFAULT_ARG, "default_arg", tcc_exceptional, 0)
+ parsing had occurred. This is used for default arguments, delayed
+ NSDMIs, and noexcept-specifier parsing. */
+DEFTREECODE (DEFERRED_PARSE, "deferred_parse", tcc_exceptional, 0)
/* An uninstantiated/unevaluated noexcept-specification. For the
uninstantiated case, DEFERRED_NOEXCEPT_PATTERN is the pattern from the
#define C_TYPE_FIELDS_READONLY(TYPE) \
(LANG_TYPE_CLASS_CHECK (TYPE)->fields_readonly)
-/* The tokens stored in the default argument. */
+/* The tokens stored in the unparsed operand. */
-#define DEFARG_TOKENS(NODE) \
- (((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->tokens)
-#define DEFARG_INSTANTIATIONS(NODE) \
- (((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->instantiations)
+#define DEFPARSE_TOKENS(NODE) \
+ (((struct tree_deferred_parse *)DEFERRED_PARSE_CHECK (NODE))->tokens)
+#define DEFPARSE_INSTANTIATIONS(NODE) \
+ (((struct tree_deferred_parse *)DEFERRED_PARSE_CHECK (NODE))->instantiations)
-struct GTY (()) tree_default_arg {
+struct GTY (()) tree_deferred_parse {
struct tree_base base;
struct cp_token_cache *tokens;
vec<tree, va_gc> *instantiations;
&& DEFERRED_NOEXCEPT_PATTERN (TREE_PURPOSE (NODE)) == NULL_TREE)
#define UNPARSED_NOEXCEPT_SPEC_P(NODE) \
((NODE) && (TREE_PURPOSE (NODE)) \
- && (TREE_CODE (TREE_PURPOSE (NODE)) == DEFAULT_ARG))
+ && (TREE_CODE (TREE_PURPOSE (NODE)) == DEFERRED_PARSE))
struct GTY (()) tree_deferred_noexcept {
struct tree_base base;
TS_CP_OVERLOAD,
TS_CP_BASELINK,
TS_CP_TEMPLATE_DECL,
- TS_CP_DEFAULT_ARG,
+ TS_CP_DEFERRED_PARSE,
TS_CP_DEFERRED_NOEXCEPT,
TS_CP_STATIC_ASSERT,
TS_CP_ARGUMENT_PACK_SELECT,
struct tree_overload GTY ((tag ("TS_CP_OVERLOAD"))) overload;
struct tree_baselink GTY ((tag ("TS_CP_BASELINK"))) baselink;
struct tree_template_decl GTY ((tag ("TS_CP_TEMPLATE_DECL"))) template_decl;
- struct tree_default_arg GTY ((tag ("TS_CP_DEFAULT_ARG"))) default_arg;
+ struct tree_deferred_parse GTY ((tag ("TS_CP_DEFERRED_PARSE"))) deferred_parse;
struct tree_deferred_noexcept GTY ((tag ("TS_CP_DEFERRED_NOEXCEPT"))) deferred_noexcept;
struct lang_identifier GTY ((tag ("TS_CP_IDENTIFIER"))) identifier;
struct tree_static_assert GTY ((tag ("TS_CP_STATIC_ASSERT")))
extern bool parsing_nsdmi (void);
extern bool parsing_default_capturing_generic_lambda_in_template (void);
extern void inject_this_parameter (tree, cp_cv_quals);
-extern location_t defarg_location (tree);
+extern location_t defparse_location (tree);
extern void maybe_show_extern_c_location (void);
extern bool literal_integer_zerop (const_tree);
for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); t; t = TREE_CHAIN (t))
if (TREE_PURPOSE (t)
- && TREE_CODE (TREE_PURPOSE (t)) == DEFAULT_ARG)
+ && TREE_CODE (TREE_PURPOSE (t)) == DEFERRED_PARSE)
{
- error_at (defarg_location (TREE_PURPOSE (t)),
+ error_at (defparse_location (TREE_PURPOSE (t)),
"default arguments are not allowed in declaration "
"of friend template specialization %qD",
decl);
tree var;
tree decl_type;
- if (TREE_CODE (arg) == DEFAULT_ARG)
- /* We get a DEFAULT_ARG when looking at an in-class declaration
+ if (TREE_CODE (arg) == DEFERRED_PARSE)
+ /* We get a DEFERRED_PARSE when looking at an in-class declaration
with a default argument. Ignore the argument for now; we'll
deal with it after the class is complete. */
return arg;
{
switch (TREE_CODE (&t->generic))
{
- case DEFAULT_ARG: return TS_CP_DEFAULT_ARG;
+ case DEFERRED_PARSE: return TS_CP_DEFERRED_PARSE;
case DEFERRED_NOEXCEPT: return TS_CP_DEFERRED_NOEXCEPT;
case IDENTIFIER_NODE: return TS_CP_IDENTIFIER;
case OVERLOAD: return TS_CP_OVERLOAD;
DECL_DECLARED_INLINE_P (value) = 1;
}
}
- else if (TREE_CODE (init) == DEFAULT_ARG)
+ else if (TREE_CODE (init) == DEFERRED_PARSE)
error ("invalid initializer for member function %qD", value);
else if (TREE_CODE (TREE_TYPE (value)) == METHOD_TYPE)
{
dump_expr (pp, TREE_OPERAND (t, 0), flags);
break;
- case DEFAULT_ARG:
+ case DEFERRED_PARSE:
pp_string (pp, M_("<unparsed>"));
break;
if (DECL_P (t))
return DECL_SOURCE_LOCATION (t);
- if (TREE_CODE (t) == DEFAULT_ARG)
- return defarg_location (t);
+ if (TREE_CODE (t) == DEFERRED_PARSE)
+ return defparse_location (t);
return cp_expr_loc_or_loc (t, input_location);
}
location_t expr_loc
= cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (member));
tree *slot;
- if (TREE_CODE (init) == DEFAULT_ARG)
+ if (TREE_CODE (init) == DEFERRED_PARSE)
/* Unparsed. */;
else if (nsdmi_inst && (slot = nsdmi_inst->get (member)))
init = *slot;
else
init = DECL_INITIAL (member);
- if (init && TREE_CODE (init) == DEFAULT_ARG)
+ if (init && TREE_CODE (init) == DEFERRED_PARSE)
{
if (complain & tf_error)
{
/* Exception handling [gram.exception] */
/* Save the tokens that make up the noexcept-specifier for a member-function.
- Returns a DEFAULT_ARG. */
+ Returns a DEFERRED_PARSE. */
static tree
cp_parser_save_noexcept (cp_parser *parser)
cp_parser_cache_group (parser, CPP_CLOSE_PAREN, /*depth=*/0);
cp_token *last = parser->lexer->next_token;
- /* As with default arguments and NSDMIs, make use of DEFAULT_ARG
+ /* As with default arguments and NSDMIs, make use of DEFERRED_PARSE
to carry the information we will need. */
- tree expr = make_node (DEFAULT_ARG);
+ tree expr = make_node (DEFERRED_PARSE);
/* Save away the noexcept-specifier; we will process it when the
class is complete. */
- DEFARG_TOKENS (expr) = cp_token_cache_new (first, last);
+ DEFPARSE_TOKENS (expr) = cp_token_cache_new (first, last);
expr = build_tree_list (expr, NULL_TREE);
return expr;
}
cp_parser_late_noexcept_specifier (cp_parser *parser, tree default_arg)
{
/* Make sure we've gotten something that hasn't been parsed yet. */
- gcc_assert (TREE_CODE (default_arg) == DEFAULT_ARG);
+ gcc_assert (TREE_CODE (default_arg) == DEFERRED_PARSE);
push_unparsed_function_queues (parser);
/* Push the saved tokens for the noexcept-specifier onto the parser's
lexer stack. */
- cp_token_cache *tokens = DEFARG_TOKENS (default_arg);
+ cp_token_cache *tokens = DEFPARSE_TOKENS (default_arg);
cp_parser_push_lexer_for_tokens (parser, tokens);
/* Parse the cached noexcept-specifier. */
}
/* Save the tokens that make up the in-class initializer for a non-static
- data member. Returns a DEFAULT_ARG. */
+ data member. Returns a DEFERRED_PARSE. */
static tree
cp_parser_save_nsdmi (cp_parser* parser)
/* Push the saved tokens for the default argument onto the parser's
lexer stack. */
- tokens = DEFARG_TOKENS (default_arg);
+ tokens = DEFPARSE_TOKENS (default_arg);
cp_parser_push_lexer_for_tokens (parser, tokens);
start_lambda_scope (decl);
}
/* FN is a FUNCTION_DECL which may contains a parameter with an
- unparsed DEFAULT_ARG. Parse the default args now. This function
+ unparsed DEFERRED_PARSE. Parse the default args now. This function
assumes that the current scope is the scope in which the default
argument should be processed. */
if (!default_arg)
continue;
- if (TREE_CODE (default_arg) != DEFAULT_ARG)
+ if (TREE_CODE (default_arg) != DEFERRED_PARSE)
/* This can happen for a friend declaration for a function
already declared with default arguments. */
continue;
TREE_PURPOSE (parm) = parsed_arg;
/* Update any instantiations we've already created. */
- for (insts = DEFARG_INSTANTIATIONS (default_arg), ix = 0;
+ for (insts = DEFPARSE_INSTANTIATIONS (default_arg), ix = 0;
vec_safe_iterate (insts, ix, ©); ix++)
TREE_PURPOSE (copy) = parsed_arg;
}
token = cp_lexer_consume_token (parser->lexer);
}
- /* Create a DEFAULT_ARG to represent the unparsed default
+ /* Create a DEFERRED_PARSE to represent the unparsed default
argument. */
- default_argument = make_node (DEFAULT_ARG);
- DEFARG_TOKENS (default_argument)
+ default_argument = make_node (DEFERRED_PARSE);
+ DEFPARSE_TOKENS (default_argument)
= cp_token_cache_new (first_token, token);
- DEFARG_INSTANTIATIONS (default_argument) = NULL;
+ DEFPARSE_INSTANTIATIONS (default_argument) = NULL;
return default_argument;
}
-/* A location to use for diagnostics about an unparsed DEFAULT_ARG. */
+/* A location to use for diagnostics about an unparsed DEFERRED_PARSE. */
location_t
-defarg_location (tree default_argument)
+defparse_location (tree default_argument)
{
- cp_token_cache *tokens = DEFARG_TOKENS (default_argument);
+ cp_token_cache *tokens = DEFPARSE_TOKENS (default_argument);
location_t start = tokens->first->location;
location_t end = tokens->last->location;
return make_location (start, start, end);
int errs = errorcount + sorrycount;
/* This can happen in invalid code. */
- if (TREE_CODE (arg) == DEFAULT_ARG)
+ if (TREE_CODE (arg) == DEFERRED_PARSE)
return arg;
tree parm = FUNCTION_FIRST_USER_PARM (fn);
default_arg = tsubst_copy_and_build (default_arg, args, complain, in_decl,
false/*fn*/, false/*constexpr*/);
- if (default_arg && TREE_CODE (default_arg) == DEFAULT_ARG)
+ if (default_arg && TREE_CODE (default_arg) == DEFERRED_PARSE)
{
/* We've instantiated a template before its default arguments
have been parsed. This can happen for a nested template
argument in a call of this function. */
remaining_arg_types =
tree_cons (default_arg, type, remaining_arg_types);
- vec_safe_push (DEFARG_INSTANTIATIONS(default_arg), remaining_arg_types);
+ vec_safe_push (DEFPARSE_INSTANTIATIONS (default_arg),
+ remaining_arg_types);
}
else
remaining_arg_types =
affect overload resolution and treating it as dependent breaks
things. Same for an unparsed noexcept expression. */
if (TREE_CODE (noex) != DEFERRED_NOEXCEPT
- && TREE_CODE (noex) != DEFAULT_ARG
+ && TREE_CODE (noex) != DEFERRED_PARSE
&& value_dependent_expression_p (noex))
return true;
return false;
case IDENTIFIER_NODE:
case SSA_NAME:
case USING_DECL:
- case DEFAULT_ARG:
+ case DEFERRED_PARSE:
return false;
case BASELINK:
result = NULL_TREE;
switch (code)
{
- case DEFAULT_ARG:
+ case DEFERRED_PARSE:
case TEMPLATE_TEMPLATE_PARM:
case BOUND_TEMPLATE_TEMPLATE_PARM:
case UNBOUND_CLASS_TEMPLATE:
provide default arguments in a language conformant
manner. */
if (fndecl && TREE_PURPOSE (typetail)
- && TREE_CODE (TREE_PURPOSE (typetail)) != DEFAULT_ARG)
+ && TREE_CODE (TREE_PURPOSE (typetail)) != DEFERRED_PARSE)
{
for (; typetail != void_list_node; ++i)
{