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: PR6486



The recent fixes for cv-qualification bugs in C++ exposed a new one.

Bootstrapped and 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-29  Mark Mitchell  <mark@codesourcery.com>

	PR c++/6486
	* method.c (do_build_copy_constructor): Avoid building
	cv-qualified reference types.
  
2002-04-29  Mark Mitchell  <mark@codesourcery.com>

	PR c++/6486
	* g++.dg/template/friend6.C: New test.

Index: gcc/cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.219.2.3
diff -c -p -r1.219.2.3 method.c
*** gcc/cp/method.c	26 Apr 2002 21:26:07 -0000	1.219.2.3
--- gcc/cp/method.c	29 Apr 2002 14:45:28 -0000
*************** do_build_copy_constructor (fndecl)
*** 562,567 ****
--- 562,568 ----
  	{
  	  tree init;
  	  tree field = fields;
+ 	  tree expr_type;
  
  	  if (TREE_CODE (field) != FIELD_DECL)
  	    continue;
*************** do_build_copy_constructor (fndecl)
*** 584,592 ****
  	  else
  	    continue;
  
! 	  init = build (COMPONENT_REF,
! 	                cp_build_qualified_type (TREE_TYPE (field), cvquals),
! 	                init, field);
  	  init = build_tree_list (NULL_TREE, init);
  
  	  member_init_list
--- 585,599 ----
  	  else
  	    continue;
  
! 	  /* Compute the type of "init->field".  If the copy-constructor
! 	     parameter is, for example, "const S&", and the type of
! 	     the field is "T", then the type will usually be "const
! 	     T".  (There are no cv-qualified variants of reference
! 	     types.)  */
! 	  expr_type = TREE_TYPE (field);
! 	  if (TREE_CODE (expr_type) != REFERENCE_TYPE)
! 	    expr_type = cp_build_qualified_type (expr_type, cvquals);
! 	  init = build (COMPONENT_REF, expr_type, init, field);
  	  init = build_tree_list (NULL_TREE, init);
  
  	  member_init_list
Index: gcc/testsuite/g++.dg/init/copy1.C
===================================================================
RCS file: gcc/testsuite/g++.dg/init/copy1.C
diff -N gcc/testsuite/g++.dg/init/copy1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/init/copy1.C	29 Apr 2002 14:45:31 -0000
***************
*** 0 ****
--- 1,21 ----
+ // { dg-do compile }
+ 
+ class A {
+ public:
+     A(){}
+     A( const A& a ){}
+ };
+ 
+ class B  : public A
+ {
+ public:
+   B( int& s) : s_(s){}
+   int& s_;
+ };
+ 
+ int main()
+ {
+   int i;
+   B x1( i );
+   B x2( x1 );
+ }


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