aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2002-04-24 06:48:44 -0400
committerJason Merrill <jason@gcc.gnu.org>2002-04-24 06:48:44 -0400
commit985723ce6c6c8b35a35e9a7a78dc96d376402667 (patch)
treebfa7381ca660b553e110d2c57f3a192fb22069ef
parent12fe8bf235afe43f72abebca8fb82ee7072afff3 (diff)
downloadgcc-985723ce6c6c8b35a35e9a7a78dc96d376402667.zip
gcc-985723ce6c6c8b35a35e9a7a78dc96d376402667.tar.gz
gcc-985723ce6c6c8b35a35e9a7a78dc96d376402667.tar.bz2
re PR c++/6331 (g++ 3.1 looses const qualifiers)
PR c++/6331 * method.c (do_build_copy_constructor): Use cp_build_qualified_type. * typeck.c (build_modify_expr): Allow arrays to differ in cv-quals. From-SVN: r52709
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/method.c2
-rw-r--r--gcc/cp/typeck.c5
-rw-r--r--gcc/testsuite/g++.dg/init/array3.C23
4 files changed, 31 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 971d0bd..0b94657 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2002-04-24 Jason Merrill <jason@redhat.com>
+ PR c++/6331
+ * method.c (do_build_copy_constructor): Use cp_build_qualified_type.
+ * typeck.c (build_modify_expr): Allow arrays to differ in cv-quals.
+
PR c++/6395
* decl.c (make_rtl_for_nonlocal_decl): Don't mess with #pragma i/i
stuff for comdats.
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 830771e..efcd5fb 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -585,7 +585,7 @@ do_build_copy_constructor (fndecl)
continue;
init = build (COMPONENT_REF,
- build_qualified_type (TREE_TYPE (field), cvquals),
+ cp_build_qualified_type (TREE_TYPE (field), cvquals),
init, field);
init = build_tree_list (NULL_TREE, init);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 690df76..10db2f8 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5665,10 +5665,11 @@ build_modify_expr (lhs, modifycode, rhs)
{
int from_array;
- if (!same_or_base_type_p (lhstype, TREE_TYPE (rhs)))
+ if (!same_or_base_type_p (TYPE_MAIN_VARIANT (lhstype),
+ TYPE_MAIN_VARIANT (TREE_TYPE (rhs))))
{
error ("incompatible types in assignment of `%T' to `%T'",
- TREE_TYPE (rhs), lhstype);
+ TREE_TYPE (rhs), lhstype);
return error_mark_node;
}
diff --git a/gcc/testsuite/g++.dg/init/array3.C b/gcc/testsuite/g++.dg/init/array3.C
new file mode 100644
index 0000000..700b263
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array3.C
@@ -0,0 +1,23 @@
+// PR c++/6331
+// Bug: we were generating a badly cv-qualified ARRAY_TYPE in the
+// synthesized copy constructor for A, which then became the canonical
+// version, confusing later uses.
+
+struct A {
+ virtual ~A();
+ const float* f();
+ float fa[3];
+};
+
+struct B {
+ B(const A& ai) : a (ai) {}
+ A a;
+};
+
+void g (const float pos[3]);
+
+extern A& a;
+void h()
+{
+ g (a.f());
+}