diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-10-14 09:59:45 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-10-14 10:04:18 -0700 |
commit | 068644a14976ce670c2b32c37e18f0aafeb05569 (patch) | |
tree | b349fda340e8e82bbbf0e80205086754dcf2e5bf /gcc/cp/friend.c | |
parent | 06bec55e80d98419121f3998d98d969990a75b0b (diff) | |
download | gcc-068644a14976ce670c2b32c37e18f0aafeb05569.zip gcc-068644a14976ce670c2b32c37e18f0aafeb05569.tar.gz gcc-068644a14976ce670c2b32c37e18f0aafeb05569.tar.bz2 |
c++: DECL_FRIEND_P cleanup
DECL_FRIEND_P's meaning has changed over time. It now (almost) means
the the friend function decl has not been met via an explicit decl.
This completes that transition, renaming it to DECL_UNIQUE_FRIEND_P,
so one doesn't think it is the sole indicator of friendliness (plenty
of friends do not have the flag set). This allows reduction in the
complexity of managing the field -- all in duplicate_decls now.
gcc/cp/
* cp-tree.h (struct lang_decl_fn): Adjust context comment.
(DECL_FRIEND_P): Replace with ...
(DECL_UNIQUE_FRIEND_P): ... this. Only for FUNCTION_DECLs.
(DECL_FRIEND_CONTEXT): Adjust.
* class.c (add_implicitly_declared_members): Detect friendly
spaceship from context.
* constraint.cc (remove_constraints): Use a checking assert.
(maybe_substitute_reqs_for): Use DECL_UNIQUE_FRIEND_P.
* decl.c (check_no_redeclaration_friend_default_args):
DECL_UNIQUE_FRIEND_P is signficant, not hiddenness.
(duplicate_decls): Adjust DECL_UNIQUE_FRIEND_P clearing.
(redeclaration_error_message): Use DECL_UNIQUE_FRIEND_P.
(start_preparsed_function): Correct in-class friend processing.
Refactor some initializers.
(grokmethod): Directly check friend decl-spec.
* decl2.c (grokfield): Check DECL_UNIQUE_FRIEND_P.
* friend.c (do_friend): Set DECL_UNIQUE_FRIEND_P first, remove
extraneous conditions. Don't re set it afterwards.
* name-lookup.c (lookup_elaborated_type_1): Simplify revealing
code.
(do_pushtag): Likewise.
* pt.c (optimize_specialization_lookup_p): Check
DECL_UNIQUE_FRIEND_P.
(push_template_decl): Likewise. Drop unneeded friend setting.
(type_dependent_expression_p): Check DECL_UNIQUE_FRIEND_P.
libcc1/
* libcp1plugin.cc (plugin_add_friend): Set DECL_UNIQUE_FRIEND_P.
Diffstat (limited to 'gcc/cp/friend.c')
-rw-r--r-- | gcc/cp/friend.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 6a783a9..56fa960 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -481,8 +481,8 @@ do_friend (tree ctype, tree declarator, tree decl, gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); gcc_assert (!ctype || MAYBE_CLASS_TYPE_P (ctype)); - /* Every decl that gets here is a friend of something. */ - DECL_FRIEND_P (decl) = 1; + /* Friend functions are unique, until proved otherwise. */ + DECL_UNIQUE_FRIEND_P (decl) = 1; if (DECL_OVERRIDE_P (decl) || DECL_FINAL_P (decl)) error ("friend declaration %qD may not have virt-specifiers", @@ -581,17 +581,11 @@ do_friend (tree ctype, tree declarator, tree decl, error ("member %qD declared as friend before type %qT defined", decl, ctype); } - /* A global friend. - @@ or possibly a friend from a base class ?!? */ - else if (TREE_CODE (decl) == FUNCTION_DECL) + else { + /* Namespace-scope friend function. */ int is_friend_template = PROCESSING_REAL_TEMPLATE_DECL_P (); - /* Friends must all go through the overload machinery, - even though they may not technically be overloaded. - - Note that because classes all wind up being top-level - in their scope, their friend wind up in top-level scope as well. */ if (funcdef_flag) SET_DECL_FRIEND_CONTEXT (decl, current_class_type); @@ -653,7 +647,6 @@ do_friend (tree ctype, tree declarator, tree decl, add_friend (current_class_type, is_friend_template ? DECL_TI_TEMPLATE (decl) : decl, /*complain=*/true); - DECL_FRIEND_P (decl) = 1; } return decl; |