Fix to c++/9336 introduces segfault

Mark Mitchell mark@codesourcery.com
Thu Mar 13 21:05:00 GMT 2003


On Thu, 2003-03-13 at 09:06, Michael Matz wrote:
> Hi Mark,
> 
> me again ;)  The patch
> 
>         PR c++/9336
>         * decl2.c (do_nonmember_using_decl): Do not call duplicate decls
>         to merge old and new declarations.

I've checked in this patch, tested on i686-pc-linux-gnu.

Applied on the mainline and on the branch.

The key thing is not to call duplicate_decls here, since the
declarations aren't in the same scope.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
-------------- next part --------------
2003-03-13  Mark Mitchell  <mark@codesourcery.com>

	* decl2.c (do_nonmember_using_decl): Correct handling of
	simultaneous type/non-type bindings.

2003-03-13  Mark Mitchell  <mark@codesourcery.com>

	* g++.dg/parse/namespace9.C: New test.

Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.606
diff -c -5 -p -r1.606 decl2.c
*** cp/decl2.c	12 Mar 2003 07:23:14 -0000	1.606
--- cp/decl2.c	13 Mar 2003 20:51:57 -0000
*************** do_nonmember_using_decl (tree scope, tre
*** 4220,4229 ****
--- 4220,4236 ----
    /* Check for using functions.  */
    if (BINDING_VALUE (decls) && is_overloaded_fn (BINDING_VALUE (decls)))
      {
        tree tmp, tmp1;
  
+       if (oldval && !is_overloaded_fn (oldval))
+ 	{
+ 	  if (!DECL_IMPLICIT_TYPEDEF_P (oldval))
+ 	    error ("`%D' is already declared in this scope", name);
+ 	  oldval = NULL_TREE;
+ 	}
+ 
        *newval = oldval;
        for (tmp = BINDING_VALUE (decls); tmp; tmp = OVL_NEXT (tmp))
  	{
  	  tree new_fn = OVL_CURRENT (tmp);
  
Index: testsuite/g++.dg/parse/namespace9.C
===================================================================
RCS file: testsuite/g++.dg/parse/namespace9.C
diff -N testsuite/g++.dg/parse/namespace9.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/namespace9.C	13 Mar 2003 20:51:58 -0000
***************
*** 0 ****
--- 1,8 ----
+ namespace A {
+   void f();
+ }
+ int g()
+ {
+   struct f { };
+   using A::f;
+ }


More information about the Gcc-patches mailing list