aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-02-16 16:21:36 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-02-16 16:21:36 +0000
commit3943b161342a68ec90a7b977cf6a8e451671e25d (patch)
tree282b1d1719ed513f3ba4f31dc34994199012094a
parentd65da12f2b93cea64a7122022208439cd282dfc2 (diff)
downloadgcc-3943b161342a68ec90a7b977cf6a8e451671e25d.zip
gcc-3943b161342a68ec90a7b977cf6a8e451671e25d.tar.gz
gcc-3943b161342a68ec90a7b977cf6a8e451671e25d.tar.bz2
[C++ PATCH] Deprecate -ffriend-injection
https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00998.html Deprecate -ffriend-injection. * decl.c (cxx_init_decl_processing): Emit warning on option. * name-lookup.c (do_pushdecl): Emit warning if we push a visible friend. * doc/extend.texi (Backwards Compatibility): Mention friend injection. Note for-scope is deprecated. * doc/invoke.texi (-ffriend-injection): Deprecate. * g++.old-deja/g++.jason/scoping15.C: Expect warnings. * g++.old-deja/g++.mike/net43.C: Likewise. From-SVN: r257742
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/name-lookup.c6
-rw-r--r--gcc/doc/extend.texi18
-rw-r--r--gcc/doc/invoke.texi3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/scoping15.C8
-rw-r--r--gcc/testsuite/g++.old-deja/g++.mike/net43.C4
9 files changed, 55 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 332a38f..d3c0645 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-16 Nathan Sidwell <nathan@acm.org>
+
+ * doc/extend.texi (Backwards Compatibility): Mention friend
+ injection. Note for-scope is deprecated.
+ * doc/invoke.texi (-ffriend-injection): Deprecate.
+
2018-02-16 Segher Boessenkool <segher@kernel.crashing.org>
* combine.c (try_combine): When adjusting LOG_LINKS for the destination
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1da0a4d..ee08e68 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2018-02-16 Nathan Sidwell <nathan@acm.org>
+
+ Deprecate -ffriend-injection.
+ * decl.c (cxx_init_decl_processing): Emit warning on option.
+ * name-lookup.c (do_pushdecl): Emit warning if we push a visible
+ friend.
+
2018-02-16 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/82468
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index fbcc778..15f7f12 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4091,8 +4091,14 @@ cxx_init_decl_processing (void)
pop_namespace ();
flag_noexcept_type = (cxx_dialect >= cxx17);
+ /* There's no fixed location for <command-line>, the current
+ location is <builtins>, which is somewhat confusing. */
if (!flag_new_for_scope)
- warning (OPT_Wdeprecated, "%<-fno-for-scope%> is deprecated");
+ warning_at (UNKNOWN_LOCATION, OPT_Wdeprecated,
+ "%<-fno-for-scope%> is deprecated");
+ if (flag_friend_injection)
+ warning_at (UNKNOWN_LOCATION, OPT_Wdeprecated,
+ "%<-ffriend-injection%> is deprecated");
c_common_nodes_and_builtins ();
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 47cee30..9117e0b 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3071,6 +3071,7 @@ do_pushdecl (tree decl, bool is_friend)
old = OVL_CHAIN (old);
check_template_shadow (decl);
+ bool visible_injection = false;
if (DECL_DECLARES_FUNCTION_P (decl))
{
@@ -3091,6 +3092,8 @@ do_pushdecl (tree decl, bool is_friend)
if (!flag_friend_injection)
/* Hide it from ordinary lookup. */
DECL_ANTICIPATED (decl) = DECL_HIDDEN_FRIEND_P (decl) = true;
+ else
+ visible_injection = true;
}
}
@@ -3142,6 +3145,9 @@ do_pushdecl (tree decl, bool is_friend)
}
else if (VAR_P (decl))
maybe_register_incomplete_var (decl);
+ else if (visible_injection)
+ warning (0, "injected friend %qD is visible"
+ " due to %<-ffriend-injection%>", decl);
if ((VAR_P (decl) || TREE_CODE (decl) == FUNCTION_DECL)
&& DECL_EXTERN_C_P (decl))
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 5c3c5ec..ee37eee 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -23881,11 +23881,23 @@ deprecated. @xref{Deprecated Features}.
@table @code
@item For scope
-If a variable is declared at for scope, it used to remain in scope until
-the end of the scope that contained the for statement (rather than just
-within the for scope). G++ retains this, but issues a warning, if such a
+If a variable is declared at for scope, it used to remain in scope
+until the end of the scope that contained the for statement (rather
+than just within the for scope). The deprecated
+@option{-fno-for-scope} option enables this non-standard behaviour.
+Without the option, G++ retains this, but issues a warning, if such a
variable is accessed outside the for scope.
+The behaviour is deprecated, only available with @option{-std=c++98}
+@option{-std=gnu++98} languages and you must use the
+@option{-fpermissive} option to enable it. The behaviour will be
+removed.
+
+@item Friend Injection
+The @option{-ffriend-injection} option makes injected friends visible
+to regular name lookup, unlike standard C++. This option is
+deprecated and will be removed.
+
@item Implicit C language
Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
scope to set the language. On such systems, all header files are
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index bcffc8c..277c99a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2451,8 +2451,7 @@ However, in ISO C++ a friend function that is not declared
in an enclosing scope can only be found using argument dependent
lookup. GCC defaults to the standard behavior.
-This option is for compatibility, and may be removed in a future
-release of G++.
+This option is deprecated and will be removed.
@item -fno-elide-constructors
@opindex fno-elide-constructors
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 068f169..0bed6c3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-16 Nathan Sidwell <nathan@acm.org>
+
+ * g++.old-deja/g++.jason/scoping15.C: Expect warnings.
+ * g++.old-deja/g++.mike/net43.C: Likewise.
+
2018-02-16 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/82468
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping15.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping15.C
index cc34c5f..69207e9 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/scoping15.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping15.C
@@ -3,14 +3,17 @@
// Bug: g++ ignores the :: qualification and dies trying to treat an integer
// variable as a list of functions.
+class DComplex;
+double imag (const DComplex&);
+
class DComplex {
public:
- friend double imag(const DComplex& a);
+ friend double imag(const DComplex& a); // Not injected, no warning
};
class FComplex {
public:
- friend float imag(const FComplex& a);
+ friend float imag(const FComplex& a); // { dg-warning "is visible"
};
void
@@ -19,3 +22,4 @@ scnrm2(FComplex cx[])
int imag;
::imag( cx[0] );
}
+// { dg-warning "ffriend-injection.* is deprecated" "" { target *-*-* } cc1plus: }
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net43.C b/gcc/testsuite/g++.old-deja/g++.mike/net43.C
index aadd03d..de266de 100644
--- a/gcc/testsuite/g++.old-deja/g++.mike/net43.C
+++ b/gcc/testsuite/g++.old-deja/g++.mike/net43.C
@@ -1,9 +1,9 @@
// { dg-do assemble }
-// { dg-options "-ffriend-injection" }
+// { dg-options "-ffriend-injection -Wno-deprecated" }
class foo {
public:
- friend int operator ^(const foo&, const foo&);
+ friend int operator ^(const foo&, const foo&); // { dg-message "is visible" }
};
int main ()