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]
Other format: [Raw text]

C++ PATCH for c++/9798


We got into an infinite recursion between two namespaces which use each
other, because we were recursing into the used namespaces before adding
ourselves to the list of currently used namespace.

Tested i686-pc-linux-gnu, applied to trunk and 3.3.  Patch in
g++.dg/lookup/using3.C.

2003-03-10  Jason Merrill  <jason at redhat dot com>

	PR c++/9798
	* decl.c (push_using_directive): Push before recursing.

*** decl.c.~1~	2003-03-10 16:41:52.000000000 -0500
--- decl.c	2003-03-10 16:39:57.000000000 -0500
*************** push_using_directive (tree used)
*** 4442,4455 ****
    if (purpose_member (used, ud) != NULL_TREE)
      POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
  
-   /* Recursively add all namespaces used.  */
-   for (iter = DECL_NAMESPACE_USING (used); iter; iter = TREE_CHAIN (iter))
-     push_using_directive (TREE_PURPOSE (iter));
- 
    ancestor = namespace_ancestor (current_decl_namespace (), used);
    ud = current_binding_level->using_directives;
    ud = tree_cons (used, ancestor, ud);
    current_binding_level->using_directives = ud;
    POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, ud);
  }
  
--- 4442,4456 ----
    if (purpose_member (used, ud) != NULL_TREE)
      POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
  
    ancestor = namespace_ancestor (current_decl_namespace (), used);
    ud = current_binding_level->using_directives;
    ud = tree_cons (used, ancestor, ud);
    current_binding_level->using_directives = ud;
+ 
+   /* Recursively add all namespaces used.  */
+   for (iter = DECL_NAMESPACE_USING (used); iter; iter = TREE_CHAIN (iter))
+     push_using_directive (TREE_PURPOSE (iter));
+ 
    POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, ud);
  }
  

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