From 6f2f4050aacf448f1e63a844845a1d0e7cde59ca Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 19 May 2017 14:12:14 +0000 Subject: [PATCH] call.c (add_list_candidates): Use OVL_FIRST. * call.c (add_list_candidates): Use OVL_FIRST. (build_new_method_call_1): Likewise. * cp-tree.h (OVL_SINGLE_P): New. (TYPE_HIDDEN_P): New. * decl.c (xref_tag_1): Use TYPE_HIDDEN_P. * dump.c (cp_tump_tree): Adjust overload dumping. * error.c (dump_decl): Use OVL_SINGLE_P, simplify context printing. * method.c (lazily_declare_fn): Assert we added it. * parser.c (cp_parser_nested_name_specifier): Use OVL_SINGLE_P, OVL_FIRST. (cp_parser_template_name): Use lkp_iterator. * pt.c (begin_template_parm_list): Fixup comment. (instantiate_class_template_1): Use TYPE_HIDDEN_P. * tree.c (ovl_iterator::remove_node): Cope with inherited ctors. (ovl_scope): Use lkp_iterator. From-SVN: r248285 --- gcc/cp/ChangeLog | 19 +++++++++++++++++++ gcc/cp/call.c | 6 +++--- gcc/cp/cp-tree.h | 9 +++++++++ gcc/cp/decl.c | 14 ++++++++------ gcc/cp/dump.c | 6 ++++-- gcc/cp/error.c | 17 ++++++++--------- gcc/cp/method.c | 3 ++- gcc/cp/parser.c | 20 +++++++++----------- gcc/cp/pt.c | 6 +++--- gcc/cp/tree.c | 15 +++++++++++---- 10 files changed, 76 insertions(+), 39 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f2dced4..08efe36 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,22 @@ +2017-05-19 Nathan Sidwell + + * call.c (add_list_candidates): Use OVL_FIRST. + (build_new_method_call_1): Likewise. + * cp-tree.h (OVL_SINGLE_P): New. + (TYPE_HIDDEN_P): New. + * decl.c (xref_tag_1): Use TYPE_HIDDEN_P. + * dump.c (cp_tump_tree): Adjust overload dumping. + * error.c (dump_decl): Use OVL_SINGLE_P, simplify context + printing. + * method.c (lazily_declare_fn): Assert we added it. + * parser.c (cp_parser_nested_name_specifier): Use OVL_SINGLE_P, + OVL_FIRST. + (cp_parser_template_name): Use lkp_iterator. + * pt.c (begin_template_parm_list): Fixup comment. + (instantiate_class_template_1): Use TYPE_HIDDEN_P. + * tree.c (ovl_iterator::remove_node): Cope with inherited ctors. + (ovl_scope): Use lkp_iterator. + 2017-05-19 Thomas Schwinge * parser.c (cp_parser_omp_clause_default): Handle diff --git a/gcc/cp/call.c b/gcc/cp/call.c index cc64202..f14c0fa 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3666,7 +3666,7 @@ add_list_candidates (tree fns, tree first_arg, avoid the copy constructor call for copy-list-initialization. */ flags |= LOOKUP_NO_NARROWING; - unsigned nart = num_artificial_parms_for (get_first_fn (fns)) - 1; + unsigned nart = num_artificial_parms_for (OVL_FIRST (fns)) - 1; tree init_list = (*args)[nart]; /* Always use the default constructor if the list is empty (DR 990). */ @@ -8539,7 +8539,7 @@ build_new_method_call_1 (tree instance, tree fns, vec **args, gcc_assert (TREE_CODE (fns) == FUNCTION_DECL || TREE_CODE (fns) == TEMPLATE_DECL || TREE_CODE (fns) == OVERLOAD); - fn = get_first_fn (fns); + fn = OVL_FIRST (fns); name = DECL_NAME (fn); basetype = TYPE_MAIN_VARIANT (TREE_TYPE (instance)); @@ -8708,7 +8708,7 @@ build_new_method_call_1 (tree instance, tree fns, vec **args, tree errname = name; if (IDENTIFIER_CTOR_OR_DTOR_P (errname)) { - tree fn = DECL_ORIGIN (get_first_fn (fns)); + tree fn = DECL_ORIGIN (OVL_FIRST (fns)); errname = DECL_NAME (fn); } if (explicit_targs) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e9e4b00..633377d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -655,6 +655,10 @@ typedef struct ptrmem_cst * ptrmem_cst_t; /* The name of the overload set. */ #define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE)) +/* Whether this is a single member overload. */ +#define OVL_SINGLE_P(NODE) \ + (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE)) + struct GTY(()) tree_overload { struct tree_common common; tree function; @@ -3750,6 +3754,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) (DECL_LANG_SPECIFIC (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK (NODE)) \ ->u.base.anticipated_p) +/* True if this is a hidden class type. */ +#define TYPE_HIDDEN_P(NODE) \ + (DECL_LANG_SPECIFIC (TYPE_NAME (NODE)) \ + && DECL_ANTICIPATED (TYPE_NAME (NODE))) + /* True for artificial decls added for OpenMP privatized non-static data members. */ #define DECL_OMP_PRIVATIZED_MEMBER(NODE) \ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7fe0be3..5877f37 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13636,16 +13636,18 @@ xref_tag_1 (enum tag_types tag_code, tree name, } /* Make injected friend class visible. */ - if (scope != ts_within_enclosing_non_class - && hidden_name_p (TYPE_NAME (t))) + if (scope != ts_within_enclosing_non_class && TYPE_HIDDEN_P (t)) { - DECL_ANTICIPATED (TYPE_NAME (t)) = 0; - DECL_FRIEND_P (TYPE_NAME (t)) = 0; + tree decl = TYPE_NAME (t); + + DECL_ANTICIPATED (decl) = false; + DECL_FRIEND_P (decl) = false; if (TYPE_TEMPLATE_INFO (t)) { - DECL_ANTICIPATED (TYPE_TI_TEMPLATE (t)) = 0; - DECL_FRIEND_P (TYPE_TI_TEMPLATE (t)) = 0; + tree tmpl = TYPE_TI_TEMPLATE (t); + DECL_ANTICIPATED (tmpl) = false; + DECL_FRIEND_P (tmpl) = false; } } } diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c index e150ae2..080fa1a 100644 --- a/gcc/cp/dump.c +++ b/gcc/cp/dump.c @@ -364,8 +364,10 @@ cp_dump_tree (void* dump_info, tree t) break; case OVERLOAD: - dump_child ("crnt", OVL_CURRENT (t)); - dump_child ("chan", OVL_CHAIN (t)); + dump_child ("name", OVL_NAME (t)); + if (!dump_flag (di, TDF_SLIM, t)) + for (lkp_iterator iter (t); iter; ++iter) + dump_child ("chld", *iter); break; case TRY_BLOCK: diff --git a/gcc/cp/error.c b/gcc/cp/error.c index e8136d3..1ae25bb 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1189,17 +1189,16 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) break; case OVERLOAD: - if (OVL_CHAIN (t)) + if (!OVL_SINGLE_P (t)) { - t = OVL_CURRENT (t); - if (DECL_CLASS_SCOPE_P (t)) + t = OVL_FIRST (t); + tree ctx = CP_DECL_CONTEXT (t); + if (ctx != global_namespace) { - dump_type (pp, DECL_CONTEXT (t), flags); - pp_cxx_colon_colon (pp); - } - else if (!DECL_FILE_SCOPE_P (t)) - { - dump_decl (pp, DECL_CONTEXT (t), flags); + if (TYPE_P (ctx)) + dump_type (pp, ctx, flags); + else + dump_decl (pp, ctx, flags); pp_cxx_colon_colon (pp); } dump_decl (pp, DECL_NAME (t), flags); diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 756b59d..8aa4f3e 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -2387,7 +2387,8 @@ lazily_declare_fn (special_function_kind sfk, tree type) || sfk == sfk_copy_assignment) check_for_override (fn, type); /* Add it to CLASSTYPE_METHOD_VEC. */ - add_method (type, fn, false); + bool added = add_method (type, fn, false); + gcc_assert (added); /* Add it to TYPE_METHODS. */ if (sfk == sfk_destructor && DECL_VIRTUAL_P (fn)) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b345110..c89dc43 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6028,8 +6028,8 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, if (is_overloaded_fn (tid)) { tree fns = get_fns (tid); - if (!OVL_CHAIN (fns)) - tmpl = OVL_CURRENT (fns); + if (OVL_SINGLE_P (fns)) + tmpl = OVL_FIRST (fns); error_at (token->location, "function template-id %qD " "in nested-name-specifier", tid); } @@ -15639,7 +15639,6 @@ cp_parser_template_name (cp_parser* parser, { tree identifier; tree decl; - tree fns; cp_token *token = cp_lexer_peek_token (parser->lexer); /* If the next token is `operator', then we have either an @@ -15765,20 +15764,19 @@ cp_parser_template_name (cp_parser* parser, } else { - tree fn = NULL_TREE; - /* The standard does not explicitly indicate whether a name that names a set of overloaded declarations, some of which are templates, is a template-name. However, such a name should be a template-name; otherwise, there is no way to form a template-id for the overloaded templates. */ - fns = BASELINK_P (decl) ? BASELINK_FUNCTIONS (decl) : decl; - if (TREE_CODE (fns) == OVERLOAD) - for (fn = fns; fn; fn = OVL_NEXT (fn)) - if (TREE_CODE (OVL_CURRENT (fn)) == TEMPLATE_DECL) - break; + bool found = false; + + for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (decl)); + !found && iter; ++iter) + if (TREE_CODE (*iter) == TEMPLATE_DECL) + found = true; - if (!fn) + if (!found) { /* The name does not name a template. */ cp_parser_error (parser, "expected template-name"); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index eef6c0e..367e58d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -648,8 +648,8 @@ begin_template_parm_list (void) template struct S2 {}; }; - pushtag contains special code to call pushdecl_with_scope on the - TEMPLATE_DECL for S2. */ + pushtag contains special code to insert the TEMPLATE_DECL for S2 + at the right scope. */ begin_scope (sk_template_parms, NULL); ++processing_template_decl; ++processing_template_parmlist; @@ -10592,7 +10592,7 @@ instantiate_class_template_1 (tree type) --processing_template_decl; } else if (!CLASSTYPE_USE_TEMPLATE (friend_type) - && hidden_name_p (TYPE_NAME (friend_type))) + && TYPE_HIDDEN_P (friend_type)) { /* friend class C; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e2d0225..8490c81 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2230,7 +2230,11 @@ ovl_iterator::remove_node (tree overload, tree node) singleton overload (and consequently maybe setting its type), because all uses of this function will be followed by inserting a new node that must follow the place we've cut this out from. */ - *slot = OVL_CHAIN (node); + if (TREE_CODE (node) != OVERLOAD) + /* Cloned inherited ctors don't mark themselves as via_using. */ + *slot = NULL_TREE; + else + *slot = OVL_CHAIN (node); return overload; } @@ -2362,9 +2366,12 @@ ovl_scope (tree ovl) if (TREE_CODE (ovl) == TEMPLATE_ID_EXPR) ovl = TREE_OPERAND (ovl, 0); /* Skip using-declarations. */ - while (TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl) && OVL_CHAIN (ovl)) - ovl = OVL_CHAIN (ovl); - return CP_DECL_CONTEXT (OVL_CURRENT (ovl)); + lkp_iterator iter (ovl); + do + ovl = *iter; + while (iter.using_p () && ++iter); + + return CP_DECL_CONTEXT (ovl); } #define PRINT_RING_SIZE 4 -- 2.7.4