mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/33486 (namespace association doesn't handle parallel namespaces)
* gcc/cp/parser.c (cp_parser_declaration): Handle 'inline namespace'.
(cp_parser_namespace_definition): Likewise.
PR c++/33486
* gcc/cp/name-lookup.c (arg_assoc_namespace): Look down into inline
namespaces, too.
* libstdc++-v3/include/bits/c++config: Use 'inline namespace'
instead of strong using.
From-SVN: r132611
This commit is contained in:
parent
c9be0915bd
commit
4cfaec1cef
|
|
@ -1,3 +1,12 @@
|
||||||
|
2008-02-24 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* parser.c (cp_parser_declaration): Handle "inline namespace".
|
||||||
|
(cp_parser_namespace_definition): Likewise.
|
||||||
|
|
||||||
|
PR c++/33486
|
||||||
|
* name-lookup.c (arg_assoc_namespace): Look down into inline
|
||||||
|
namespaces, too.
|
||||||
|
|
||||||
2008-02-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
2008-02-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||||
|
|
||||||
* typeck.c (check_for_casting_away_constness): Use 1 single
|
* typeck.c (check_for_casting_away_constness): Use 1 single
|
||||||
|
|
|
||||||
|
|
@ -4419,6 +4419,13 @@ arg_assoc_namespace (struct arg_lookup *k, tree scope)
|
||||||
if (arg_assoc_namespace (k, TREE_PURPOSE (value)))
|
if (arg_assoc_namespace (k, TREE_PURPOSE (value)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
/* Also look down into inline namespaces. */
|
||||||
|
for (value = DECL_NAMESPACE_USING (scope); value;
|
||||||
|
value = TREE_CHAIN (value))
|
||||||
|
if (is_associated_namespace (scope, TREE_PURPOSE (value)))
|
||||||
|
if (arg_assoc_namespace (k, TREE_PURPOSE (value)))
|
||||||
|
return true;
|
||||||
|
|
||||||
value = namespace_binding (k->name, scope);
|
value = namespace_binding (k->name, scope);
|
||||||
if (!value)
|
if (!value)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -7737,6 +7737,10 @@ cp_parser_declaration (cp_parser* parser)
|
||||||
|| token2.type == CPP_OPEN_BRACE
|
|| token2.type == CPP_OPEN_BRACE
|
||||||
|| token2.keyword == RID_ATTRIBUTE))
|
|| token2.keyword == RID_ATTRIBUTE))
|
||||||
cp_parser_namespace_definition (parser);
|
cp_parser_namespace_definition (parser);
|
||||||
|
/* An inline (associated) namespace definition. */
|
||||||
|
else if (token1.keyword == RID_INLINE
|
||||||
|
&& token2.keyword == RID_NAMESPACE)
|
||||||
|
cp_parser_namespace_definition (parser);
|
||||||
/* Objective-C++ declaration/definition. */
|
/* Objective-C++ declaration/definition. */
|
||||||
else if (c_dialect_objc () && OBJC_IS_AT_KEYWORD (token1.keyword))
|
else if (c_dialect_objc () && OBJC_IS_AT_KEYWORD (token1.keyword))
|
||||||
cp_parser_objc_declaration (parser);
|
cp_parser_objc_declaration (parser);
|
||||||
|
|
@ -11562,6 +11566,15 @@ cp_parser_namespace_definition (cp_parser* parser)
|
||||||
{
|
{
|
||||||
tree identifier, attribs;
|
tree identifier, attribs;
|
||||||
bool has_visibility;
|
bool has_visibility;
|
||||||
|
bool is_inline;
|
||||||
|
|
||||||
|
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_INLINE))
|
||||||
|
{
|
||||||
|
is_inline = true;
|
||||||
|
cp_lexer_consume_token (parser->lexer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
is_inline = false;
|
||||||
|
|
||||||
/* Look for the `namespace' keyword. */
|
/* Look for the `namespace' keyword. */
|
||||||
cp_parser_require_keyword (parser, RID_NAMESPACE, "`namespace'");
|
cp_parser_require_keyword (parser, RID_NAMESPACE, "`namespace'");
|
||||||
|
|
@ -11583,6 +11596,21 @@ cp_parser_namespace_definition (cp_parser* parser)
|
||||||
/* Start the namespace. */
|
/* Start the namespace. */
|
||||||
push_namespace (identifier);
|
push_namespace (identifier);
|
||||||
|
|
||||||
|
/* "inline namespace" is equivalent to a stub namespace definition
|
||||||
|
followed by a strong using directive. */
|
||||||
|
if (is_inline)
|
||||||
|
{
|
||||||
|
tree namespace = current_namespace;
|
||||||
|
/* Set up namespace association. */
|
||||||
|
DECL_NAMESPACE_ASSOCIATIONS (namespace)
|
||||||
|
= tree_cons (CP_DECL_CONTEXT (namespace), NULL_TREE,
|
||||||
|
DECL_NAMESPACE_ASSOCIATIONS (namespace));
|
||||||
|
/* Import the contents of the inline namespace. */
|
||||||
|
pop_namespace ();
|
||||||
|
do_using_directive (namespace);
|
||||||
|
push_namespace (identifier);
|
||||||
|
}
|
||||||
|
|
||||||
has_visibility = handle_namespace_attrs (current_namespace, attribs);
|
has_visibility = handle_namespace_attrs (current_namespace, attribs);
|
||||||
|
|
||||||
/* Parse the body of the namespace. */
|
/* Parse the body of the namespace. */
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@
|
||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
|
|
||||||
namespace fool {
|
namespace fool {
|
||||||
namespace foo {
|
inline namespace foo {
|
||||||
template <class T> void swap(T, T);
|
template <class T> void swap(T, T);
|
||||||
}
|
}
|
||||||
using namespace foo __attribute__((strong));
|
|
||||||
template <class T> void swap(T);
|
template <class T> void swap(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,14 @@
|
||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
|
|
||||||
namespace foo {
|
namespace foo {
|
||||||
namespace foo_impl {
|
inline namespace foo_impl {
|
||||||
class T; // { dg-error "T" "" }
|
class T; // { dg-error "T" "" }
|
||||||
}
|
}
|
||||||
using namespace foo_impl __attribute__((strong));
|
|
||||||
}
|
}
|
||||||
namespace bar {
|
namespace bar {
|
||||||
namespace bar_impl {
|
inline namespace bar_impl {
|
||||||
class T; // { dg-error "T" "" }
|
class T; // { dg-error "T" "" }
|
||||||
}
|
}
|
||||||
using namespace bar_impl __attribute__((strong));
|
|
||||||
using namespace foo;
|
using namespace foo;
|
||||||
}
|
}
|
||||||
namespace baz {
|
namespace baz {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@
|
||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
|
|
||||||
namespace bar {
|
namespace bar {
|
||||||
namespace foo {
|
inline namespace foo {
|
||||||
template <class T> void f(T, T);
|
template <class T> void f(T, T);
|
||||||
}
|
}
|
||||||
using namespace foo __attribute__((strong));
|
|
||||||
template <class T> void f(T);
|
template <class T> void f(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
// PR c++/33486
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2008-02-20 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* include/bits/c++config: Use 'inline namespace' instead of
|
||||||
|
strong using.
|
||||||
|
|
||||||
2008-02-18 Pedro Lamarao <pedro.lamarao@mndfck.org>
|
2008-02-18 Pedro Lamarao <pedro.lamarao@mndfck.org>
|
||||||
|
|
||||||
* include/std/tuple: Fixes for moveable, non-copyable types.
|
* include/std/tuple: Fixes for moveable, non-copyable types.
|
||||||
|
|
|
||||||
|
|
@ -180,11 +180,8 @@
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
namespace __norm { }
|
namespace __norm { }
|
||||||
namespace __debug { }
|
inline namespace __debug { }
|
||||||
namespace __cxx1998 { }
|
inline namespace __cxx1998 { }
|
||||||
|
|
||||||
using namespace __debug __attribute__ ((strong));
|
|
||||||
using namespace __cxx1998 __attribute__ ((strong));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -193,11 +190,8 @@ namespace std
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
namespace __norm { }
|
namespace __norm { }
|
||||||
namespace __parallel { }
|
inline namespace __parallel { }
|
||||||
namespace __cxx1998 { }
|
inline namespace __cxx1998 { }
|
||||||
|
|
||||||
using namespace __parallel __attribute__ ((strong));
|
|
||||||
using namespace __cxx1998 __attribute__ ((strong));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -205,22 +199,19 @@ namespace std
|
||||||
#if _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION
|
#if _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
namespace _6 { }
|
inline namespace _6 { }
|
||||||
using namespace _6 __attribute__ ((strong));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace __gnu_cxx
|
namespace __gnu_cxx
|
||||||
{
|
{
|
||||||
namespace _6 { }
|
inline namespace _6 { }
|
||||||
using namespace _6 __attribute__ ((strong));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
namespace tr1
|
namespace tr1
|
||||||
{
|
{
|
||||||
namespace _6 { }
|
inline namespace _6 { }
|
||||||
using namespace _6 __attribute__ ((strong));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -235,8 +226,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
# define _GLIBCXX_LDBL_NAMESPACE __gnu_cxx_ldbl128::
|
# define _GLIBCXX_LDBL_NAMESPACE __gnu_cxx_ldbl128::
|
||||||
# define _GLIBCXX_BEGIN_LDBL_NAMESPACE namespace __gnu_cxx_ldbl128 {
|
# define _GLIBCXX_BEGIN_LDBL_NAMESPACE namespace __gnu_cxx_ldbl128 {
|
||||||
# define _GLIBCXX_END_LDBL_NAMESPACE }
|
# define _GLIBCXX_END_LDBL_NAMESPACE }
|
||||||
namespace __gnu_cxx_ldbl128 { }
|
inline namespace __gnu_cxx_ldbl128 { }
|
||||||
using namespace __gnu_cxx_ldbl128 __attribute__((__strong__));
|
|
||||||
#else
|
#else
|
||||||
# define _GLIBCXX_LDBL_NAMESPACE
|
# define _GLIBCXX_LDBL_NAMESPACE
|
||||||
# define _GLIBCXX_BEGIN_LDBL_NAMESPACE
|
# define _GLIBCXX_BEGIN_LDBL_NAMESPACE
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue