Commit 1c4320eb by Nathan Sidwell Committed by Nathan Sidwell

[C++ PATCH] Using decls

https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01411.html
	* name-lookup.c (do_nonmember_using_decl): Drop INSERT_P
	parameter.  Document.
	(finish_nonmember_using_decl): Adjust do_nonmember_using_decl
	calls.  Remove stray FIXME comment.

From-SVN: r271471
parent 8c365be6
2019-05-21 Nathan Sidwell <nathan@acm.org> 2019-05-21 Nathan Sidwell <nathan@acm.org>
* name-lookup.c (do_nonmember_using_decl): Drop INSERT_P
parameter. Document.
(finish_nonmember_using_decl): Adjust do_nonmember_using_decl
calls. Remove stray FIXME comment.
* name-lookup.h (struct cp_binding_level): Drop usings field. * name-lookup.h (struct cp_binding_level): Drop usings field.
(finish_namespace_using_decl, finish_local_using_decl): Replace with ... (finish_namespace_using_decl, finish_local_using_decl): Replace with ...
(finish_nonmember_using_decl): ... this. (finish_nonmember_using_decl): ... this.
......
...@@ -3882,15 +3882,16 @@ pushdecl_outermost_localscope (tree x) ...@@ -3882,15 +3882,16 @@ pushdecl_outermost_localscope (tree x)
return ret; return ret;
} }
/* Process a local-scope or namespace-scope using declaration. /* Process a local-scope or namespace-scope using declaration. LOOKUP
FIXME is the result of qualified lookup (both value & type are
is the nominated scope to search for NAME. VALUE_P and TYPE_P significant). FN_SCOPE_P indicates if we're at function-scope (as
point to the binding for NAME in the current scope and are opposed to namespace-scope). *VALUE_P and *TYPE_P are the current
updated. */ bindings, which are altered to reflect the newly brought in
declarations. */
static bool static bool
do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p,
bool insert_p, tree *value_p, tree *type_p) tree *value_p, tree *type_p)
{ {
tree value = *value_p; tree value = *value_p;
tree type = *type_p; tree type = *type_p;
...@@ -3957,7 +3958,7 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, ...@@ -3957,7 +3958,7 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p,
} }
} }
if (!found && insert_p) if (!found)
/* Unlike the decl-pushing case we don't drop anticipated /* Unlike the decl-pushing case we don't drop anticipated
builtins here. They don't cause a problem, and we'd builtins here. They don't cause a problem, and we'd
like to match them with a future declaration. */ like to match them with a future declaration. */
...@@ -3972,7 +3973,7 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, ...@@ -3972,7 +3973,7 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p,
diagnose_name_conflict (lookup.value, value); diagnose_name_conflict (lookup.value, value);
failed = true; failed = true;
} }
else if (insert_p) else
value = lookup.value; value = lookup.value;
if (lookup.type && lookup.type != type) if (lookup.type && lookup.type != type)
...@@ -3982,21 +3983,18 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, ...@@ -3982,21 +3983,18 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p,
diagnose_name_conflict (lookup.type, type); diagnose_name_conflict (lookup.type, type);
failed = true; failed = true;
} }
else if (insert_p) else
type = lookup.type; type = lookup.type;
} }
if (insert_p) /* If value is empty, shift any class or enumeration name back. */
if (!value)
{ {
/* If value is empty, shift any class or enumeration name back. */ value = type;
if (!value) type = NULL_TREE;
{
value = type;
type = NULL_TREE;
}
*value_p = value;
*type_p = type;
} }
*value_p = value;
*type_p = type;
return failed; return failed;
} }
...@@ -5080,7 +5078,7 @@ finish_nonmember_using_decl (tree scope, tree name) ...@@ -5080,7 +5078,7 @@ finish_nonmember_using_decl (tree scope, tree name)
tree value = MAYBE_STAT_DECL (*slot); tree value = MAYBE_STAT_DECL (*slot);
tree type = MAYBE_STAT_TYPE (*slot); tree type = MAYBE_STAT_TYPE (*slot);
do_nonmember_using_decl (lookup, false, true, &value, &type); do_nonmember_using_decl (lookup, false, &value, &type);
if (STAT_HACK_P (*slot)) if (STAT_HACK_P (*slot))
{ {
...@@ -5110,7 +5108,7 @@ finish_nonmember_using_decl (tree scope, tree name) ...@@ -5110,7 +5108,7 @@ finish_nonmember_using_decl (tree scope, tree name)
/* DR 36 questions why using-decls at function scope may not be /* DR 36 questions why using-decls at function scope may not be
duplicates. Disallow it, as C++11 claimed and PR 20420 duplicates. Disallow it, as C++11 claimed and PR 20420
implemented. */ implemented. */
do_nonmember_using_decl (lookup, true, true, &value, &type); do_nonmember_using_decl (lookup, true, &value, &type);
if (!value) if (!value)
; ;
...@@ -5123,7 +5121,6 @@ finish_nonmember_using_decl (tree scope, tree name) ...@@ -5123,7 +5121,6 @@ finish_nonmember_using_decl (tree scope, tree name)
} }
else else
/* Install the new binding. */ /* Install the new binding. */
// FIXME: Short circuit P_L_B
push_local_binding (name, value, true); push_local_binding (name, value, true);
if (!type) if (!type)
......
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