This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: C++ (parser) regression?




--On Tuesday, August 13, 2002 03:09:40 PM +0200 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> wrote:

On 13 Aug 2002, Gabriel Dos Reis wrote:
|   % cat x.cc
|   #include <set>
|
|   using namespace std;
|
|   class C : public set<int> {
|       void add(const int i) {
|           insert(i);
|           }
|       };
Fixed with the attached patch.

This was a latent bug; we were silently treating overloaded functions
as equivalent to the first function in the overload set for name-lookup
purposes.  As long as we looked up every name multiple times, we only
had to get it right the last time; now that we're not so wasteful we
have to get it right all the time.

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

--
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

2002-08-13  Mark Mitchell  <mark@codesourcery.com>

	* decl.c (pushdecl_class_level): Honor requests to bind names to
	OVERLOADs.

2002-08-13  Mark Mitchell  <mark@codesourcery.com>

	* g++.dg/template/inherit3: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.930
diff -c -p -r1.930 decl.c
*** cp/decl.c	11 Aug 2002 16:05:27 -0000	1.930
--- cp/decl.c	13 Aug 2002 16:32:47 -0000
*************** void
*** 4259,4271 ****
 pushdecl_class_level (x)
      tree x;
 {
!   /* Don't use DECL_ASSEMBLER_NAME here!  Everything that looks in class
!      scope looks for the pre-mangled name.  */
!   register tree name;

   if (TREE_CODE (x) == OVERLOAD)
!     x = OVL_CURRENT (x);
!   name = DECL_NAME (x);

   if (name)
     {
--- 4259,4271 ----
 pushdecl_class_level (x)
      tree x;
 {
!   tree name;

+   /* Get the name of X.  */
   if (TREE_CODE (x) == OVERLOAD)
!     name = DECL_NAME (get_first_fn (x));
!   else
!     name = DECL_NAME (x);

   if (name)
     {
*************** pushdecl_class_level (x)
*** 4275,4285 ****
     }
   else if (ANON_AGGR_TYPE_P (TREE_TYPE (x)))
     {
       tree f;

!       for (f = TYPE_FIELDS (TREE_TYPE (x));
! 	   f;
! 	   f = TREE_CHAIN (f))
 	pushdecl_class_level (f);
     }
 }
--- 4275,4286 ----
     }
   else if (ANON_AGGR_TYPE_P (TREE_TYPE (x)))
     {
+       /* If X is an anonymous aggregate, all of its members are
+ 	 treated as if they were members of the class containing the
+ 	 aggregate, for naming purposes.  */
       tree f;

!       for (f = TYPE_FIELDS (TREE_TYPE (x)); f; f = TREE_CHAIN (f))
 	pushdecl_class_level (f);
     }
 }
Index: testsuite/g++.dg/template/inherit3.C
===================================================================
RCS file: testsuite/g++.dg/template/inherit3.C
diff -N testsuite/g++.dg/template/inherit3.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/inherit3.C	13 Aug 2002 16:34:29 -0000
***************
*** 0 ****
--- 1,12 ----
+ template <typename T>
+ struct set {
+   void insert (const T&);
+   template <class X>
+   void insert  (X, X);
+ };
+
+ struct C : public set<int> {
+   void f (const int i) {
+     insert (i);
+   }
+ };


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