aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2005-09-12 19:54:23 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2005-09-12 19:54:23 +0000
commitd63d5d0c32c03cd13765216b9107414849b1f05d (patch)
tree672854ad16a126bb970ef26565b6d30c3cb8e167 /gcc/doc
parentdbc564aea36c6a2a6c3dc7d3a6e2614f47a4d920 (diff)
downloadgcc-d63d5d0c32c03cd13765216b9107414849b1f05d.zip
gcc-d63d5d0c32c03cd13765216b9107414849b1f05d.tar.gz
gcc-d63d5d0c32c03cd13765216b9107414849b1f05d.tar.bz2
re PR c++/7874 (g++ finds friend functions defined in class-definition but not declared in the enclosing namespace)
./ PR g++/7874 * c.opt (ffriend-injection): New C++ option. * doc/invoke.texi (Option Summary): Mention -ffriend-injection. (C++ Dialect Options): Document -ffriend-injection. cp/ PR g++/7874 * cp-tree.h (struct lang_decl_flags): Add hidden_friend_p bitfield. Make dummy bitfield one bit smaller. (DECL_HIDDEN_FRIEND_P): Define. (pushdecl_maybe_friend): Declare. (pushdecl_top_level_maybe_friend): Declare. * decl.c (duplicate_decls): Add newdecl_is_friend parameter. Change prototype and all callers. Add assertion that a DECL_ARTIFICIAL FUNCTION_DECL is not DECL_HIDDEN_FRIEND_P. Set DECL_ANTICIPATED and DECL_HIDDEN_FRIEND_P in duplicated decl if appropriate. * name-lookup.c (supplement_binding): Don't ignore a DECL_HIDDEN_FRIEND_P. (pushdecl_maybe_friend): Break out contents of pushdecl. Add is_friend parameter. Set DECL_ANTICIPATED and DECL_HIDDEN_FRIEND_P for a friend function. (pushdecl): Just call pushdecl_maybe_friend. (pushdecl_with_scope): Add is_friend parameter. Change prototype and all callers. (pushdecl_namespace_level): Likewise. (push_overloaded_decl): Likewise. Check DECL_HIDDEN_FRIEND_P as well as DECL_ANTICIPATED when checking for a builtin. (do_nonmember_using_decl): Check DECL_HIDDEN_FRIEND_P as well as DECL_ANTICIPATED when checking for a builtin. (do_nonmember_using_decl): Likewise. (pushdecl_top_level_1): Add is_friend parameter. Change all callers. (pushdecl_top_level_maybe_friend): New function. (remove_hidden_names): New function. (struct arg_lookup): Add args field. (friend_of_associated_class_p): New static function. (arg_assoc_namespace): Ignore hidden functions which are not friends of an associated class of some argument. (lookup_arg_dependent): Remove hidden functions from list passed in. Initialize k.args. * name-lookup.h (remove_hidden_names): Declare. * friend.c (do_friend): Call pushdecl_maybe_friend instead of pushdecl. * call.c (add_function_candidate): Change DECL_ANTICIPATED test to an assertion, with a check for DECL_HIDDEN_FRIEND_P. (build_new_function_call): Add koenig_p parameter. Change prototype and callers. * pt.c (register_specialization): Add is_friend parameter. Change all callers. (push_template_decl_real): Change is_friend parameter to bool. Change prototype and all callers. (tsubst_friend_class): Call pushdecl_top_level_maybe_friend instead of pushdecl_top_level. testsuite/ PR g++/7874 * g++.dg/lookup/friend7.C: New test. * g++.dg/lookup/friend8.C: New test. * g++.dg/parse/defarg4.C: Add a parameter to the friend function, so that it will be found via argument dependent lookup. * g++.old-deja/g++.brendan/crash56.C: Don't expect errors for friend functions which will no longer be found. * g++.old-deja/g++.jason/friend.C: Add a parameter to the friend function g, so that it will be found via argument dependent lookup. * g++.old-deja/g++.jason/scoping15.C: Use -ffriend-injection. * g++.old-deja/g++.mike/net43.C: Likewise. From-SVN: r104188
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 7dfa3a4..55cf558 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -171,7 +171,7 @@ in the following sections.
@item C++ Language Options
@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
@gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol
--fconserve-space -fno-const-strings @gol
+-fconserve-space -ffriend-injection -fno-const-strings @gol
-fno-elide-constructors @gol
-fno-enforce-eh-specs @gol
-ffor-scope -fno-for-scope -fno-gnu-keywords @gol
@@ -1425,6 +1425,20 @@ two definitions were merged.
This option is no longer useful on most targets, now that support has
been added for putting variables into BSS without making them common.
+@item -ffriend-injection
+@opindex ffriend-injection
+Inject friend functions into the enclosing namespace, so that they are
+visible outside the scope of the class in which they are declared.
+Friend functions were documented to work this way in the old Annotated
+C++ Reference Manual, and versions of G++ before 4.1 always worked
+that way. However, in ISO C++ a friend function which is not declared
+in an enclosing scope can only be found using argument dependent
+lookup. This option causes friends to be injected as they were in
+earlier releases.
+
+This option is for compatibility, and may be removed in a future
+release of G++.
+
@item -fno-const-strings
@opindex fno-const-strings
Give string constants type @code{char *} instead of type @code{const