diff options
author | Nathan Sidwell <nathan@acm.org> | 2019-05-20 12:46:54 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2019-05-20 12:46:54 +0000 |
commit | 0841bc15630c18bac94ff6ed8ba2d878d639caf6 (patch) | |
tree | 30fd45fa42c65b70401f1e8101ce5b2dd80078bb | |
parent | ab904df5f9063cf3075ae20b97cf4df9e6612cc1 (diff) | |
download | gcc-0841bc15630c18bac94ff6ed8ba2d878d639caf6.zip gcc-0841bc15630c18bac94ff6ed8ba2d878d639caf6.tar.gz gcc-0841bc15630c18bac94ff6ed8ba2d878d639caf6.tar.bz2 |
[C++ PATCH] namespace using directives
https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01245.html
* cp-tree.h (struct lang_decl_ns): Remove usings field.
(DECL_NAMESPACE_USING): Delete.
* name-lookup.c (name_lookup::search_usings): Use namespace's
binding scope.
(name_lookup::queue_namespae): Likewise.
(finish_namespace_using_directive, push_namespace): Likewise.
(has_using_namespace_std_directive): Just search the entire
binding stack.
From-SVN: r271416
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 8 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 20 |
3 files changed, 17 insertions, 22 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c8eb936..b9d1284 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2019-05-20 Nathan Sidwell <nathan@acm.org> + + * cp-tree.h (struct lang_decl_ns): Remove usings field. + (DECL_NAMESPACE_USING): Delete. + * name-lookup.c (name_lookup::search_usings): Use namespace's + binding scope. + (name_lookup::queue_namespae): Likewise. + (finish_namespace_using_directive, push_namespace): Likewise. + (has_using_namespace_std_directive): Just search the entire + binding stack. + 2019-05-20 Jonathan Wakely <jwakely@redhat.com> PR c++/90532 Ensure __is_constructible(T[]) is false diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 2b19bc1..0e45ac6 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2668,9 +2668,7 @@ struct GTY(()) lang_decl_ns { struct lang_decl_base base; cp_binding_level *level; - /* using directives and inline children. These need to be va_gc, - because of PCH. */ - vec<tree, va_gc> *usings; + /* Inline children. These need to be va_gc, because of PCH. */ vec<tree, va_gc> *inlinees; /* Hash table of bound decls. It'd be nice to have this inline, but @@ -3259,10 +3257,6 @@ struct GTY(()) lang_decl { #define DECL_NAMESPACE_INLINE_P(NODE) \ TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE)) -/* In a NAMESPACE_DECL, a vector of using directives. */ -#define DECL_NAMESPACE_USING(NODE) \ - (LANG_DECL_NS_CHECK (NODE)->usings) - /* In a NAMESPACE_DECL, a vector of inline namespaces. */ #define DECL_NAMESPACE_INLINEES(NODE) \ (LANG_DECL_NS_CHECK (NODE)->inlinees) diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index d8d71be..58f3265 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -589,7 +589,7 @@ name_lookup::search_usings (tree scope) return true; bool found = false; - if (vec<tree, va_gc> *usings = DECL_NAMESPACE_USING (scope)) + if (vec<tree, va_gc> *usings = NAMESPACE_LEVEL (scope)->using_directives) for (unsigned ix = usings->length (); ix--;) found |= search_qualified ((*usings)[ix], true); @@ -651,7 +651,7 @@ name_lookup::queue_namespace (using_queue *queue, int depth, tree scope) queue = queue_namespace (queue, depth, (*inlinees)[ix]); /* Queue its using targets. */ - queue = queue_usings (queue, depth, DECL_NAMESPACE_USING (scope)); + queue = queue_usings (queue, depth, NAMESPACE_LEVEL (scope)->using_directives); return queue; } @@ -5272,21 +5272,11 @@ has_using_namespace_std_directive_p () { /* Look at local using-directives. */ for (cp_binding_level *level = current_binding_level; - level->kind != sk_namespace; + level; level = level->level_chain) if (using_directives_contain_std_p (level->using_directives)) return true; - /* Look at this namespace and its ancestors. */ - for (tree scope = current_namespace; scope; scope = CP_DECL_CONTEXT (scope)) - { - if (using_directives_contain_std_p (DECL_NAMESPACE_USING (scope))) - return true; - - if (scope == global_namespace) - break; - } - return false; } @@ -7253,7 +7243,7 @@ finish_namespace_using_directive (tree target, tree attribs) if (target == error_mark_node) return; - add_using_namespace (DECL_NAMESPACE_USING (current_namespace), + add_using_namespace (current_binding_level->using_directives, ORIGINAL_NAMESPACE (target)); emit_debug_info_using_namespace (current_namespace, ORIGINAL_NAMESPACE (target), false); @@ -7404,7 +7394,7 @@ push_namespace (tree name, bool make_inline) SET_DECL_ASSEMBLER_NAME (ns, anon_identifier); if (!make_inline) - add_using_namespace (DECL_NAMESPACE_USING (current_namespace), + add_using_namespace (current_binding_level->using_directives, ns); } else if (TREE_PUBLIC (current_namespace)) |