* 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
+2017-05-19 Nathan Sidwell <nathan@acm.org>
+
+ * 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 <thomas@codesourcery.com>
* parser.c (cp_parser_omp_clause_default): Handle
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). */
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));
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)
/* 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;
(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) \
}
/* 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;
}
}
}
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:
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);
|| 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))
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);
}
{
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
}
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");
template <class T> 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;
--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;
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;
}
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);
}
\f
#define PRINT_RING_SIZE 4