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


This patch fixes a serious regression: we were throwing away cv-qualifiers
when merging declarations.  Oops.

Bootstrapped and tested on i686-pc-linux-gnu; committed on the mainline
and on the branch.

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

002-04-23  Mark Mitchell  <mark@codesourcery.com>

	PR c++/6331:
	* typeck.c (merge_types): Remember the cv-qualification of pointer
	types when merging them.

Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.388.2.6
diff -c -p -r1.388.2.6 typeck.c
*** cp/typeck.c	12 Apr 2002 11:00:25 -0000	1.388.2.6
--- cp/typeck.c	23 Apr 2002 08:31:37 -0000
*************** merge_types (t1, t2)
*** 592,603 ****
--- 592,605 ----
        /* For two pointers, do this recursively on the target type.  */
        {
  	tree target = merge_types (TREE_TYPE (t1), TREE_TYPE (t2));
+ 	int quals = cp_type_quals (t1);

  	if (code1 == POINTER_TYPE)
  	  t1 = build_pointer_type (target);
  	else
  	  t1 = build_reference_type (target);
  	t1 = build_type_attribute_variant (t1, attributes);
+ 	t1 = cp_build_qualified_type (t1, quals);

  	if (TREE_CODE (target) == METHOD_TYPE)
  	  t1 = build_ptrmemfunc_type (t1);
Index: testsuite/g++.dg/template/qual1.C
===================================================================
RCS file: testsuite/g++.dg/template/qual1.C
diff -N testsuite/g++.dg/template/qual1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/qual1.C	23 Apr 2002 08:31:37 -0000
***************
*** 0 ****
--- 1,21 ----
+ // { dg-do compile }
+
+ template<class T>
+ class Link_array
+ {
+ public:
+   void sort (int (*compare) (T *const&,T *const&));
+ };
+
+ int shift_compare (int *const &, int *const &) {};
+
+ template<class T> void
+ Link_array<T>::sort (int (*compare) (T *const&,T *const&))
+ {
+ }
+
+ void f ()
+ {
+   Link_array<int> clashes;
+   clashes.sort (shift_compare);
+ }


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