Hi,
we ICE on the C++11 version of the GNU visibility attribute on a
namespace. I suppose we want to accept it, then just use
get_attribute_name instead of TREE_PURPOSE. The bug report also asked
for an example in the docs of attribute on a namespace declaration.
Tested x86_64-linux.
Thanks,
Paolo.
///////////////
2013-10-16 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/58724
* doc/extend.texi [visibility ("visibility_type")]: Add example
about visibility attribute on namespace declaration.
/cp
2013-10-16 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/58724
* name-lookup.c (handle_namespace_attrs): Use get_attribute_name.
/testsuite
2013-10-16 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/58724
* g++.dg/cpp0x/gen-attrs-56.C: New.
Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c (revision 203691)
+++ cp/name-lookup.c (working copy)
@@ -3571,7 +3571,7 @@ handle_namespace_attrs (tree ns, tree attributes)
for (d = attributes; d; d = TREE_CHAIN (d))
{
- tree name = TREE_PURPOSE (d);
+ tree name = get_attribute_name (d);
tree args = TREE_VALUE (d);
if (is_attribute_p ("visibility", name))
Index: doc/extend.texi
===================================================================
--- doc/extend.texi (revision 203691)
+++ doc/extend.texi (working copy)
@@ -4220,6 +4220,12 @@ the One Definition Rule; for example, it is usuall
an inline method as hidden without marking the whole class as hidden.
A C++ namespace declaration can also have the visibility attribute.
+
+@smallexample
+namespace nspace1 __attribute__ ((visibility ("protected")))
+@{ /* @r{Do something.} */; @}
+@end smallexample
+
This attribute applies only to the particular namespace body, not to
other definitions of the same namespace; it is equivalent to using
@samp{#pragma GCC visibility} before and after the namespace
Index: testsuite/g++.dg/cpp0x/gen-attrs-56.C
===================================================================
--- testsuite/g++.dg/cpp0x/gen-attrs-56.C (revision 0)
+++ testsuite/g++.dg/cpp0x/gen-attrs-56.C (working copy)
@@ -0,0 +1,5 @@
+// PR c++/58724
+// { dg-do compile { target c++11 } }
+
+namespace foo __attribute__((visibility("default"))) {}
+namespace bar [[gnu::visibility("default")]] {}