This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++ PATCH to decl_namespace_list


We weren't clearing decl_namespace_list properly across template
instantiations, which caused confusion.

Applied to trunk only.

2001-04-12  Jason Merrill  <jason_merrill@redhat.com>

	* cp-tree.h (decl_namespace_list): New macro.
	(struct saved_scope): Add decl_ns_list.
	* decl.c (mark_saved_scope): Mark it.
	* decl2.c: Lose static decl_namespace_list.
	(init_decl2): Don't save it.

*** cp-tree.h.~1~	Thu Apr 12 16:28:29 2001
--- cp-tree.h	Thu Apr 12 23:41:49 2001
*************** extern tree cp_global_trees[CPTI_MAX];
*** 779,787 ****
  
  /* Global state.  */
  
! struct saved_scope {
    tree old_bindings;
    tree old_namespace;
    tree class_name;
    tree class_type;
    tree access_specifier;
--- 779,789 ----
  
  /* Global state.  */
  
! struct saved_scope
! {
    tree old_bindings;
    tree old_namespace;
+   tree decl_ns_list;
    tree class_name;
    tree class_type;
    tree access_specifier;
*************** struct saved_scope {
*** 811,816 ****
--- 813,822 ----
  /* The current open namespace.  */
  
  #define current_namespace scope_chain->old_namespace
+ 
+ /* The stack for namespaces of current declarations. */
+ 
+ #define decl_namespace_list scope_chain->decl_ns_list
  
  /* IDENTIFIER_NODE: name of current class */
  
*** decl.c.~1~	Thu Apr 12 16:28:29 2001
--- decl.c	Thu Apr 12 15:51:55 2001
*************** mark_saved_scope (arg)
*** 2426,2431 ****
--- 2426,2432 ----
        mark_binding_level (&t->class_bindings);
        ggc_mark_tree (t->old_bindings);
        ggc_mark_tree (t->old_namespace);
+       ggc_mark_tree (t->decl_ns_list);
        ggc_mark_tree (t->class_name);
        ggc_mark_tree (t->class_type);
        ggc_mark_tree (t->access_specifier);
*************** unqualified_namespace_lookup (name, flag
*** 5754,5760 ****
       tree *spacesp;
  {
    tree b = make_node (CPLUS_BINDING);
!   tree initial = current_decl_namespace();
    tree scope = initial;
    tree siter;
    struct binding_level *level;
--- 5755,5761 ----
       tree *spacesp;
  {
    tree b = make_node (CPLUS_BINDING);
!   tree initial = current_decl_namespace ();
    tree scope = initial;
    tree siter;
    struct binding_level *level;
*** decl2.c.~1~	Thu Apr 12 16:28:29 2001
--- decl2.c	Thu Apr 12 15:51:25 2001
*************** tree static_dtors;
*** 127,137 ****
  /* The :: namespace. */
  
  tree global_namespace;
- 
- /* The stack for namespaces of current declarations. */
- 
- static tree decl_namespace_list;
- 
  
  /* C (and C++) language-specific option variables.  */
  
--- 127,132 ----
*************** handle_class_head (aggr, scope, id)
*** 5374,5380 ****
  void
  init_decl2 ()
  {
-   ggc_add_tree_root (&decl_namespace_list, 1);
    ggc_add_tree_varray_root (&deferred_fns, 1);
    ggc_add_tree_varray_root (&pending_statics, 1);
    ggc_add_tree_varray_root (&ssdf_decls, 1);
--- 5369,5374 ----

// Test that pushing into a namespace for a definition doesn't affect
// template instantiations.

// Build don't link:

namespace N {
  template <class T> void f () { }
  template <class T> struct A { friend void f<T>(); };
};

namespace M {
  struct B;
};

struct M::B: public N::A<int> { };

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]