C++ PATCH: PR 9336

Mark Mitchell mark@codesourcery.com
Wed Mar 12 07:26:00 GMT 2003


This patch fixes PR 9336, a case where G++ went into an infinte loop.

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

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

	PR c++/9336
	* decl2.c (do_nonmember_using_decl): Do not call duplicate decls
	to merge old and new declarations.

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

	PR c++/9336
	* g++.dg/parse/namespace8.C: New test.

Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.605
diff -c -5 -p -r1.605 decl2.c
*** cp/decl2.c	11 Mar 2003 23:07:42 -0000	1.605
--- cp/decl2.c	12 Mar 2003 07:20:00 -0000
*************** do_nonmember_using_decl (tree scope, tre
*** 4220,4235 ****
    /* Check for using functions.  */
    if (BINDING_VALUE (decls) && is_overloaded_fn (BINDING_VALUE (decls)))
      {
        tree tmp, tmp1;
  
-       if (oldval && !is_overloaded_fn (oldval))
- 	{
- 	  duplicate_decls (OVL_CURRENT (BINDING_VALUE (decls)), oldval);
- 	  oldval = NULL_TREE;
- 	}
- 
        *newval = oldval;
        for (tmp = BINDING_VALUE (decls); tmp; tmp = OVL_NEXT (tmp))
  	{
  	  tree new_fn = OVL_CURRENT (tmp);
  
--- 4220,4229 ----
*************** do_nonmember_using_decl (tree scope, tre
*** 4288,4303 ****
  	}
      }
    else 
      {
        *newval = BINDING_VALUE (decls);
!       if (oldval)
! 	duplicate_decls (*newval, oldval);
!     } 
  
    *newtype = BINDING_TYPE (decls);
!   if (oldtype && *newtype && oldtype != *newtype)
      {
        error ("using declaration `%D' introduced ambiguous type `%T'",
  		name, oldtype);
        return;
      }
--- 4282,4297 ----
  	}
      }
    else 
      {
        *newval = BINDING_VALUE (decls);
!       if (oldval && !decls_match (*newval, oldval))
! 	error ("`%D' is already declared in this scope", name);
!     }
  
    *newtype = BINDING_TYPE (decls);
!   if (oldtype && *newtype && !same_type_p (oldtype, *newtype))
      {
        error ("using declaration `%D' introduced ambiguous type `%T'",
  		name, oldtype);
        return;
      }
Index: testsuite/g++.dg/parse/namespace8.C
===================================================================
RCS file: testsuite/g++.dg/parse/namespace8.C
diff -N testsuite/g++.dg/parse/namespace8.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/namespace8.C	12 Mar 2003 07:20:00 -0000
***************
*** 0 ****
--- 1,6 ----
+ namespace X {
+   typedef struct {
+   } x;
+ }
+ typedef X::x x;
+ using X::x;



More information about the Gcc-patches mailing list