From: Jason Merrill Date: Thu, 26 Jan 2017 15:32:22 +0000 (-0500) Subject: * name-lookup.c (parse_using_directive): Deprecate strong using. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5668970a07f9e44a67c67600909911c757cd05fd;p=gcc.git * name-lookup.c (parse_using_directive): Deprecate strong using. From-SVN: r244936 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 90b1671e6f0..48d69525425 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2017-01-26 Jason Merrill + * name-lookup.c (parse_using_directive): Deprecate strong using. + PR c++/79176 - lambda ICE with -flto -Os * decl2.c (vague_linkage_p): Handle decloned 'tors. * tree.c (decl_linkage): Likewise. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 4004640a60c..10fb540e1f1 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4125,6 +4125,8 @@ parse_using_directive (tree name_space, tree attribs) tree name = get_attribute_name (a); if (is_attribute_p ("strong", name)) { + warning (OPT_Wdeprecated, "strong using is deprecated; use inline " + "namespaces instead"); if (!toplevel_bindings_p ()) error ("strong using only meaningful at namespace scope"); else if (name_space != error_mark_node) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 5cb4748e032..20eba822d54 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -21802,7 +21802,6 @@ Predefined Macros,cpp,The GNU C Preprocessor}). method denoted by a @samp{->*} or @samp{.*} expression. * C++ Attributes:: Variable, function, and type attributes for C++ only. * Function Multiversioning:: Declaring multiple function versions. -* Namespace Association:: Strong using-directives for namespace association. * Type Traits:: Compiler support for type traits. * C++ Concepts:: Improved support for generic programming. * Deprecated Features:: Things will disappear from G++. @@ -22368,8 +22367,6 @@ does not have constructors or destructors. @end table -See also @ref{Namespace Association}. - @node Function Multiversioning @section Function Multiversioning @cindex function versions @@ -22428,51 +22425,6 @@ dispatching to call the right version at runtime. Refer to the @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on Function Multiversioning} for more details. -@node Namespace Association -@section Namespace Association - -@strong{Caution:} The semantics of this extension are equivalent -to C++ 2011 inline namespaces. Users should use inline namespaces -instead as this extension will be removed in future versions of G++. - -A using-directive with @code{__attribute ((strong))} is stronger -than a normal using-directive in two ways: - -@itemize @bullet -@item -Templates from the used namespace can be specialized and explicitly -instantiated as though they were members of the using namespace. - -@item -The using namespace is considered an associated namespace of all -templates in the used namespace for purposes of argument-dependent -name lookup. -@end itemize - -The used namespace must be nested within the using namespace so that -normal unqualified lookup works properly. - -This is useful for composing a namespace transparently from -implementation namespaces. For example: - -@smallexample -namespace std @{ - namespace debug @{ - template struct A @{ @}; - @} - using namespace debug __attribute ((__strong__)); - template <> struct A @{ @}; // @r{OK to specialize} - - template void f (A); -@} - -int main() -@{ - f (std::A()); // @r{lookup finds} std::f - f (std::A()); -@} -@end smallexample - @node Type Traits @section Type Traits diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns6.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns6.C new file mode 100644 index 00000000000..aa0c5f9be15 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns6.C @@ -0,0 +1,16 @@ +// PR c++/13594 (secondary) + +// { dg-options "" } +// { dg-do compile } + +namespace fool { + inline namespace foo { + template void swap(T, T); + } + template void swap(T); +} + +int main() { + // we used to fail to look up the associated namespace here + fool::swap(1, 1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns7.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns7.C new file mode 100644 index 00000000000..d9f99a8d128 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns7.C @@ -0,0 +1,24 @@ +// PR c++/13594 + +// { dg-options "" } +// { dg-do compile } + +namespace foo { + inline namespace foo_impl { + class T; // { dg-message "T" "" } + } +} +namespace bar { + inline namespace bar_impl { + class T; // { dg-message "T" "" } + } + using namespace foo; +} +namespace baz { + using namespace foo; + using namespace bar; +} + +foo::T *t1; +bar::T *t2; +baz::T *t3; // { dg-error "(ambiguous|does not name a type)" "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns8.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns8.C new file mode 100644 index 00000000000..7679c6f1dc7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns8.C @@ -0,0 +1,18 @@ +// PR c++/13659 + +// { dg-options "" } +// { dg-do compile } + +namespace bar { + inline namespace foo { + template void f(T, T); + } + template void f(T); +} + +int main() { + // Make sure both declarations are brought in. + using bar::f; + f(1); + f(1, 1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns9.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns9.C new file mode 100644 index 00000000000..555adb0c9b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns9.C @@ -0,0 +1,26 @@ +// PR c++/33486 + +// { dg-options "" } + +namespace A +{ + inline namespace B + { + struct T + { + struct U { }; + U f(); + }; + } + + inline namespace C + { + void g (T::U); + } +} + +int main() +{ + A::T t; + g(t.f()); +} diff --git a/gcc/testsuite/g++.dg/lookup/strong-using-1.C b/gcc/testsuite/g++.dg/lookup/strong-using-1.C deleted file mode 100644 index aa0c5f9be15..00000000000 --- a/gcc/testsuite/g++.dg/lookup/strong-using-1.C +++ /dev/null @@ -1,16 +0,0 @@ -// PR c++/13594 (secondary) - -// { dg-options "" } -// { dg-do compile } - -namespace fool { - inline namespace foo { - template void swap(T, T); - } - template void swap(T); -} - -int main() { - // we used to fail to look up the associated namespace here - fool::swap(1, 1); -} diff --git a/gcc/testsuite/g++.dg/lookup/strong-using-2.C b/gcc/testsuite/g++.dg/lookup/strong-using-2.C deleted file mode 100644 index d9f99a8d128..00000000000 --- a/gcc/testsuite/g++.dg/lookup/strong-using-2.C +++ /dev/null @@ -1,24 +0,0 @@ -// PR c++/13594 - -// { dg-options "" } -// { dg-do compile } - -namespace foo { - inline namespace foo_impl { - class T; // { dg-message "T" "" } - } -} -namespace bar { - inline namespace bar_impl { - class T; // { dg-message "T" "" } - } - using namespace foo; -} -namespace baz { - using namespace foo; - using namespace bar; -} - -foo::T *t1; -bar::T *t2; -baz::T *t3; // { dg-error "(ambiguous|does not name a type)" "" } diff --git a/gcc/testsuite/g++.dg/lookup/strong-using-3.C b/gcc/testsuite/g++.dg/lookup/strong-using-3.C deleted file mode 100644 index 7679c6f1dc7..00000000000 --- a/gcc/testsuite/g++.dg/lookup/strong-using-3.C +++ /dev/null @@ -1,18 +0,0 @@ -// PR c++/13659 - -// { dg-options "" } -// { dg-do compile } - -namespace bar { - inline namespace foo { - template void f(T, T); - } - template void f(T); -} - -int main() { - // Make sure both declarations are brought in. - using bar::f; - f(1); - f(1, 1); -} diff --git a/gcc/testsuite/g++.dg/lookup/strong-using-4.C b/gcc/testsuite/g++.dg/lookup/strong-using-4.C deleted file mode 100644 index 5ea17844a63..00000000000 --- a/gcc/testsuite/g++.dg/lookup/strong-using-4.C +++ /dev/null @@ -1,8 +0,0 @@ -// PR c++/16301 - -// { dg-do compile } - -namespace NS2 -{ - using namespace NS1 __attribute__ ((strong)); // { dg-error "" } -} diff --git a/gcc/testsuite/g++.dg/lookup/strong-using-5.C b/gcc/testsuite/g++.dg/lookup/strong-using-5.C deleted file mode 100644 index 555adb0c9b1..00000000000 --- a/gcc/testsuite/g++.dg/lookup/strong-using-5.C +++ /dev/null @@ -1,26 +0,0 @@ -// PR c++/33486 - -// { dg-options "" } - -namespace A -{ - inline namespace B - { - struct T - { - struct U { }; - U f(); - }; - } - - inline namespace C - { - void g (T::U); - } -} - -int main() -{ - A::T t; - g(t.f()); -} diff --git a/libstdc++-v3/doc/html/manual/debug_mode_design.html b/libstdc++-v3/doc/html/manual/debug_mode_design.html index 3373471d48e..3fcdb2db885 100644 --- a/libstdc++-v3/doc/html/manual/debug_mode_design.html +++ b/libstdc++-v3/doc/html/manual/debug_mode_design.html @@ -250,7 +250,6 @@ namespace std }; } // namespace __cxx1998 - // namespace __debug __attribute__ ((strong)); inline namespace __debug { } }
Link- and run-time coexistence of release- and diff --git a/libstdc++-v3/doc/xml/manual/debug_mode.xml b/libstdc++-v3/doc/xml/manual/debug_mode.xml index ff2f1cced89..9e97a1ddbe7 100644 --- a/libstdc++-v3/doc/xml/manual/debug_mode.xml +++ b/libstdc++-v3/doc/xml/manual/debug_mode.xml @@ -656,7 +656,6 @@ namespace std }; } // namespace __cxx1998 - // namespace __debug __attribute__ ((strong)); inline namespace __debug { } }