Commit 0c29f2a2 by Nathan Sidwell Committed by Nathan Sidwell

name-lookup.c (do_class_using_decl): Elide read-once temps.

	* name-lookup.c (do_class_using_decl): Elide read-once temps.
	Move declarations to initializations.

From-SVN: r251738
parent fcaf3065
2017-09-05 Nathan Sidwell <nathan@acm.org> 2017-09-05 Nathan Sidwell <nathan@acm.org>
* name-lookup.c (do_class_using_decl): Elide read-once temps.
Move declarations to initializations.
* class.c (add_method): Move slot search and insertion to ... * class.c (add_method): Move slot search and insertion to ...
* name-lookup.c (get_method_slot): ... this new function. * name-lookup.c (get_method_slot): ... this new function.
(lookup_fnfields_slot_nolazy): Cope with NULL slot. (lookup_fnfields_slot_nolazy): Cope with NULL slot.
......
...@@ -4560,20 +4560,6 @@ push_class_level_binding (tree name, tree x) ...@@ -4560,20 +4560,6 @@ push_class_level_binding (tree name, tree x)
tree tree
do_class_using_decl (tree scope, tree name) do_class_using_decl (tree scope, tree name)
{ {
/* The USING_DECL returned by this function. */
tree value;
/* The declaration (or declarations) name by this using
declaration. NULL if we are in a template and cannot figure out
what has been named. */
tree decl;
/* True if SCOPE is a dependent type. */
bool scope_dependent_p;
/* True if SCOPE::NAME is dependent. */
bool name_dependent_p;
/* True if any of the bases of CURRENT_CLASS_TYPE are dependent. */
bool bases_dependent_p;
tree binfo;
if (name == error_mark_node) if (name == error_mark_node)
return NULL_TREE; return NULL_TREE;
...@@ -4589,6 +4575,7 @@ do_class_using_decl (tree scope, tree name) ...@@ -4589,6 +4575,7 @@ do_class_using_decl (tree scope, tree name)
error ("%<%T::%D%> names destructor", scope, name); error ("%<%T::%D%> names destructor", scope, name);
return NULL_TREE; return NULL_TREE;
} }
/* Using T::T declares inheriting ctors, even if T is a typedef. */ /* Using T::T declares inheriting ctors, even if T is a typedef. */
if (MAYBE_CLASS_TYPE_P (scope) if (MAYBE_CLASS_TYPE_P (scope)
&& (name == TYPE_IDENTIFIER (scope) && (name == TYPE_IDENTIFIER (scope)
...@@ -4598,6 +4585,8 @@ do_class_using_decl (tree scope, tree name) ...@@ -4598,6 +4585,8 @@ do_class_using_decl (tree scope, tree name)
name = ctor_identifier; name = ctor_identifier;
CLASSTYPE_NON_AGGREGATE (current_class_type) = true; CLASSTYPE_NON_AGGREGATE (current_class_type) = true;
} }
/* Cannot introduce a constructor name. */
if (constructor_name_p (name, current_class_type)) if (constructor_name_p (name, current_class_type))
{ {
error ("%<%T::%D%> names constructor in %qT", error ("%<%T::%D%> names constructor in %qT",
...@@ -4605,15 +4594,6 @@ do_class_using_decl (tree scope, tree name) ...@@ -4605,15 +4594,6 @@ do_class_using_decl (tree scope, tree name)
return NULL_TREE; return NULL_TREE;
} }
scope_dependent_p = dependent_scope_p (scope);
name_dependent_p = (scope_dependent_p
|| (IDENTIFIER_CONV_OP_P (name)
&& dependent_type_p (TREE_TYPE (name))));
bases_dependent_p = any_dependent_bases_p ();
decl = NULL_TREE;
/* From [namespace.udecl]: /* From [namespace.udecl]:
A using-declaration used as a member-declaration shall refer to a A using-declaration used as a member-declaration shall refer to a
...@@ -4624,14 +4604,18 @@ do_class_using_decl (tree scope, tree name) ...@@ -4624,14 +4604,18 @@ do_class_using_decl (tree scope, tree name)
class type. Morover, if SCOPE is dependent, it might match a class type. Morover, if SCOPE is dependent, it might match a
non-dependent base. */ non-dependent base. */
if (!scope_dependent_p) tree decl = NULL_TREE;
if (!dependent_scope_p (scope))
{ {
base_kind b_kind; base_kind b_kind;
binfo = lookup_base (current_class_type, scope, ba_any, &b_kind, tree binfo = lookup_base (current_class_type, scope, ba_any, &b_kind,
tf_warning_or_error); tf_warning_or_error);
if (b_kind < bk_proper_base) if (b_kind < bk_proper_base)
{ {
if (!bases_dependent_p || b_kind == bk_same_type) /* If there are dependent bases, scope might resolve at
instantiation time, even if it isn't exactly one of the
dependent bases. */
if (b_kind == bk_same_type || !any_dependent_bases_p ())
{ {
error_not_base_type (scope, current_class_type); error_not_base_type (scope, current_class_type);
return NULL_TREE; return NULL_TREE;
...@@ -4642,7 +4626,8 @@ do_class_using_decl (tree scope, tree name) ...@@ -4642,7 +4626,8 @@ do_class_using_decl (tree scope, tree name)
error ("cannot inherit constructors from indirect base %qT", scope); error ("cannot inherit constructors from indirect base %qT", scope);
return NULL_TREE; return NULL_TREE;
} }
else if (!name_dependent_p) else if (!IDENTIFIER_CONV_OP_P (name)
|| !dependent_type_p (TREE_TYPE (name)))
{ {
decl = lookup_member (binfo, name, 0, false, tf_warning_or_error); decl = lookup_member (binfo, name, 0, false, tf_warning_or_error);
if (!decl) if (!decl)
...@@ -4651,13 +4636,14 @@ do_class_using_decl (tree scope, tree name) ...@@ -4651,13 +4636,14 @@ do_class_using_decl (tree scope, tree name)
scope); scope);
return NULL_TREE; return NULL_TREE;
} }
/* The binfo from which the functions came does not matter. */ /* The binfo from which the functions came does not matter. */
if (BASELINK_P (decl)) if (BASELINK_P (decl))
decl = BASELINK_FUNCTIONS (decl); decl = BASELINK_FUNCTIONS (decl);
} }
} }
value = build_lang_decl (USING_DECL, name, NULL_TREE); tree value = build_lang_decl (USING_DECL, name, NULL_TREE);
USING_DECL_DECLS (value) = decl; USING_DECL_DECLS (value) = decl;
USING_DECL_SCOPE (value) = scope; USING_DECL_SCOPE (value) = scope;
DECL_DEPENDENT_P (value) = !decl; DECL_DEPENDENT_P (value) = !decl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment