C++ PATCH: Fix PR6479

Mark Mitchell mark@codesourcery.com
Fri Apr 26 15:36:00 GMT 2002


This patches a regression reported today; we were looking up a base
class operator= without indicating how we found the base, which meant
the access-checking code didn't get the right answer.

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

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

2002-04-26  Mark Mitchell  <mark@codesourcery.com>

	PR c++/6479
	* method.c (do_build_assign_ref): Pass a derivation to
	build_method_call when calling base class assignment operators.

2002-04-26  Mark Mitchell  <mark@codesourcery.com>

	PR c++/6479
	* g++.dg/inherit/access2.C: New test.
	
Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.219.2.2
diff -c -p -r1.219.2.2 method.c
*** cp/method.c	24 Apr 2002 10:49:56 -0000	1.219.2.2
--- cp/method.c	26 Apr 2002 21:07:19 -0000
*************** do_build_assign_ref (fndecl)
*** 636,642 ****
  	  tree expr = build_method_call (dst,
  					 ansi_assopname (NOP_EXPR),
  					 build_tree_list (NULL_TREE, src),
! 					 NULL,
  					 LOOKUP_NORMAL | LOOKUP_NONVIRTUAL);
  	  finish_expr_stmt (expr);
  	}
--- 636,642 ----
  	  tree expr = build_method_call (dst,
  					 ansi_assopname (NOP_EXPR),
  					 build_tree_list (NULL_TREE, src),
! 					 binfo,
  					 LOOKUP_NORMAL | LOOKUP_NONVIRTUAL);
  	  finish_expr_stmt (expr);
  	}
Index: testsuite/g++.dg/inherit/access2.C
===================================================================
RCS file: testsuite/g++.dg/inherit/access2.C
diff -N testsuite/g++.dg/inherit/access2.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/inherit/access2.C	26 Apr 2002 21:07:21 -0000
***************
*** 0 ****
--- 1,16 ----
+ // { dg-do compile }
+
+ class A {
+ protected:
+   A& operator=( const A& a ) { return *this; }
+ };
+
+ class B : public A
+ {};
+
+ int main()
+ {
+   B x;
+   B y;
+   x = y;
+ }



More information about the Gcc-patches mailing list