From 7b49e3dad8692b6a6a8e7d16914489525609f764 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Sun, 23 Jun 2019 15:10:00 +0000 Subject: [PATCH] Rename DEFAULT_ARG to DEFERRED_PARSE. From-SVN: r272600 --- gcc/cp/ChangeLog | 47 ++++++++++++++++++++++++++++++++++++++++ gcc/cp/call.c | 2 +- gcc/cp/cp-objcp-common.c | 2 +- gcc/cp/cp-tree.def | 8 +++---- gcc/cp/cp-tree.h | 20 ++++++++--------- gcc/cp/decl.c | 10 ++++----- gcc/cp/decl2.c | 2 +- gcc/cp/error.c | 6 ++--- gcc/cp/init.c | 4 ++-- gcc/cp/parser.c | 36 +++++++++++++++--------------- gcc/cp/pt.c | 9 ++++---- gcc/cp/tree.c | 4 ++-- gcc/cp/typeck.c | 2 +- 13 files changed, 100 insertions(+), 52 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 800ae29a380..f47df489a3d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,50 @@ +2019-06-23 Marek Polacek + + * 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 PR c++/86476 - noexcept-specifier is a complete-class context. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 8367ef7b557..e4923f4ccbf 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7674,7 +7674,7 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum, /* 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 " diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index a8f7db0854a..21d162e5d0c 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -67,7 +67,7 @@ cp_tree_size (enum tree_code code) 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); diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 475c584fd4c..4db1d316124 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -207,11 +207,11 @@ DEFTREECODE (USING_DECL, "using_decl", tcc_declaration, 0) /* 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 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 2c05e638915..bf47f67721e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1182,14 +1182,14 @@ enum cp_identifier_kind { #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 *instantiations; @@ -1208,7 +1208,7 @@ struct GTY (()) tree_default_arg { && 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; @@ -1589,7 +1589,7 @@ enum cp_tree_node_structure_enum { 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, @@ -1610,7 +1610,7 @@ union GTY((desc ("cp_tree_node_structure (&%h)"), 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"))) @@ -6704,7 +6704,7 @@ extern void cp_finish_omp_range_for (tree, tree); 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); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8a82c754ef7..5d49535b0d9 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8963,9 +8963,9 @@ grokfndecl (tree ctype, 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); @@ -13089,8 +13089,8 @@ check_default_argument (tree decl, tree arg, tsubst_flags_t complain) 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; @@ -16661,7 +16661,7 @@ cp_tree_node_structure (union lang_tree_node * t) { 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; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 338db4ab6de..206f04c6320 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -920,7 +920,7 @@ grokfield (const cp_declarator *declarator, 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) { diff --git a/gcc/cp/error.c b/gcc/cp/error.c index d94f5a3b667..baeba7e1722 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2661,7 +2661,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) dump_expr (pp, TREE_OPERAND (t, 0), flags); break; - case DEFAULT_ARG: + case DEFERRED_PARSE: pp_string (pp, M_("")); break; @@ -3050,8 +3050,8 @@ location_of (tree t) 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); } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index e962113d154..d0f73ff1938 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -564,7 +564,7 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain) 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; @@ -629,7 +629,7 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain) else init = DECL_INITIAL (member); - if (init && TREE_CODE (init) == DEFAULT_ARG) + if (init && TREE_CODE (init) == DEFERRED_PARSE) { if (complain & tf_error) { diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 4d4d32973d9..e9bdfab443e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -25267,7 +25267,7 @@ cp_parser_base_specifier (cp_parser* parser) /* 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) @@ -25277,12 +25277,12 @@ 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; } @@ -25295,13 +25295,13 @@ static tree 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. */ @@ -28718,7 +28718,7 @@ cp_parser_save_member_function_body (cp_parser* parser, } /* 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) @@ -28955,7 +28955,7 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl, /* 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); @@ -29022,7 +29022,7 @@ cp_parser_late_parsing_nsdmi (cp_parser *parser, tree field) } /* 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. */ @@ -29060,7 +29060,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) 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; @@ -29072,7 +29072,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) 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; } @@ -30239,22 +30239,22 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi) 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); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fb89b933524..00e436429ce 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12814,7 +12814,7 @@ tsubst_default_argument (tree fn, int parmnum, tree type, tree arg, 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); @@ -14092,7 +14092,7 @@ tsubst_arg_types (tree arg_types, 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 @@ -14100,7 +14100,8 @@ tsubst_arg_types (tree arg_types, 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 = @@ -25315,7 +25316,7 @@ dependent_type_p_r (tree type) 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; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index ebfe362595f..37e24a1669c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3657,7 +3657,7 @@ cp_tree_equal (tree t1, tree t2) case IDENTIFIER_NODE: case SSA_NAME: case USING_DECL: - case DEFAULT_ARG: + case DEFERRED_PARSE: return false; case BASELINK: @@ -4788,7 +4788,7 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func, result = NULL_TREE; switch (code) { - case DEFAULT_ARG: + case DEFERRED_PARSE: case TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM: case UNBOUND_CLASS_TEMPLATE: diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a8fb1624b48..550064cf9fd 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4104,7 +4104,7 @@ convert_arguments (tree typelist, vec **values, tree fndecl, 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) { -- 2.30.2