2017-05-30 Nathan Sidwell <nathan@acm.org>
+ * cp-tree.def (OVERLOAD): Fix comment.
+ * cp-tree.h: Fix comments and whitespace.
+ * error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope.
+ * name-lookup.c (add_decl_to_level): Assert not class.
+ (check_local_shadow): Use OVL_P.
+ (pushdecl_with_scope_1): Rename to ...
+ (do_pushdecl_with_Scope): ... here.
+ (do_nonmember_using_decl): Use qualified_namespace_lookup return
+ value.
+ (push_class_level_binding_1): Use OVL_P.
+ (pushdecl_namespace_level): Use do_pushdecl_with_scope.
+ (pushtag_1): Rename to ...
+ (do_pushtag): ... here. Adjust do_pushdecl_with_scope call.
+ (pushtag): Adjust.
+ (store_class_bindings): Do not time here.
+ * name-lookup.h (pushdecl_outermost_localscope): Reorder.
+ * pt.c (listify): Declare argvec at point of initialization.
+
PR c++/80913
* name-lookup.c (add_decl_to_level): Assert not making a circular
chain.
tree function;
};
-/* Iterator for a 1 dimensional overload. */
+/* Iterator for a 1 dimensional overload. Permits iterating over the
+ outer level of a 2-d overload when explicitly enabled. */
class ovl_iterator
{
(LANG_IDENTIFIER_CAST (NODE)->class_template_info)
/* The IDENTIFIER_BINDING is the innermost cxx_binding for the
- identifier. It's PREVIOUS is the next outermost binding. Each
+ identifier. Its PREVIOUS is the next outermost binding. Each
VALUE field is a DECL for the associated declaration. Thus,
name lookup consists simply of pulling off the node at the front
of the list (modulo oddities for looking up the names of types,
userdef_literal;
};
+\f
/* Global state. */
struct GTY(()) saved_scope {
unsigned static_function : 1;
unsigned pure_virtual : 1;
unsigned defaulted_p : 1;
-
unsigned has_in_charge_parm_p : 1;
unsigned has_vtt_parm_p : 1;
+
unsigned pending_inline_p : 1;
unsigned nonconverting : 1;
unsigned thunk_p : 1;
static void
add_decl_to_level (cp_binding_level *b, tree decl)
{
- /* We used to record virtual tables as if they were ordinary
- variables, but no longer do so. */
- gcc_assert (!(VAR_P (decl) && DECL_VIRTUAL_P (decl)));
+ gcc_assert (b->kind != sk_class);
- if (TREE_CODE (decl) == NAMESPACE_DECL
- && !DECL_NAMESPACE_ALIAS (decl))
+ if (TREE_CODE (decl) == NAMESPACE_DECL && !DECL_NAMESPACE_ALIAS (decl))
{
+ /* Inner namespaces get their own chain, to make walking
+ simpler. */
DECL_CHAIN (decl) = b->namespaces;
b->namespaces = decl;
}
/* Warn if a variable shadows a non-function, or the variable
is a function or a pointer-to-function. */
- if ((TREE_CODE (member) != FUNCTION_DECL
- && TREE_CODE (member) != OVERLOAD)
+ if (!OVL_P (member)
|| TREE_CODE (decl) == FUNCTION_DECL
|| TYPE_PTRFN_P (TREE_TYPE (decl))
|| TYPE_PTRMEMFUNC_P (TREE_TYPE (decl)))
closer binding level than LEVEL. */
static tree
-pushdecl_with_scope_1 (tree x, cp_binding_level *level, bool is_friend)
+do_pushdecl_with_scope (tree x, cp_binding_level *level, bool is_friend)
{
cp_binding_level *b;
tree function_decl = current_function_decl;
n->kind != sk_function_parms; n = b->level_chain)
b = n;
- tree ret = b ? pushdecl_with_scope_1 (x, b, false) : error_mark_node;
+ tree ret = b ? do_pushdecl_with_scope (x, b, false) : error_mark_node;
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return ret;
name_lookup lookup (name, 0);
if (!qualified_namespace_lookup (scope, &lookup))
- /* Lookup error */
- return;
-
- if (!lookup.value)
{
error ("%qD not declared", name);
return;
}
}
else if (TREE_CODE (target_decl) == OVERLOAD
- && is_overloaded_fn (target_bval))
+ && OVL_P (target_bval))
old_decl = bval;
else if (TREE_CODE (decl) == USING_DECL
&& TREE_CODE (bval) == USING_DECL
&& DECL_DEPENDENT_P (bval))
return true;
else if (TREE_CODE (decl) == USING_DECL
- && is_overloaded_fn (target_bval))
+ && OVL_P (target_bval))
old_decl = bval;
else if (TREE_CODE (bval) == USING_DECL
- && is_overloaded_fn (target_decl))
+ && OVL_P (target_decl))
return true;
if (old_decl && binding->scope == class_binding_level)
tree t;
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
- t = pushdecl_with_scope_1
+ t = do_pushdecl_with_scope
(x, NAMESPACE_LEVEL (current_namespace), is_friend);
/* Now, the type_shadowed stack may screw us. Munge it so it does
Returns TYPE upon success and ERROR_MARK_NODE otherwise. */
static tree
-pushtag_1 (tree name, tree type, tag_scope scope)
+do_pushtag (tree name, tree type, tag_scope scope)
{
- cp_binding_level *b;
tree decl;
- b = current_binding_level;
+ cp_binding_level *b = current_binding_level;
while (/* Cleanup scopes are not scopes from the point of view of
the language. */
b->kind == sk_cleanup
}
else if (b->kind != sk_template_parms)
{
- decl = pushdecl_with_scope_1 (decl, b, /*is_friend=*/false);
+ decl = do_pushdecl_with_scope (decl, b, /*is_friend=*/false);
if (decl == error_mark_node)
return decl;
return type;
}
-/* Wrapper for pushtag_1. */
+/* Wrapper for do_pushtag. */
tree
pushtag (tree name, tree type, tag_scope scope)
{
tree ret;
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
- ret = pushtag_1 (name, type, scope);
+ ret = do_pushtag (name, type, scope);
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return ret;
}
size_t i;
cp_class_binding *cb;
- bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
for (i = 0; vec_safe_iterate (names, i, &cb); ++i)
if (store_binding_p (cb->identifier))
bindings_need_stored.safe_push (cb->identifier);
store_binding (id, old_bindings);
bindings_need_stored.truncate (0);
}
- timevar_cond_stop (TV_NAME_LOOKUP, subtime);
}
/* A chain of saved_scope structures awaiting reuse. */