]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/6331 (g++ 3.1 looses const qualifiers)
authorJason Merrill <jason@redhat.com>
Wed, 24 Apr 2002 10:48:44 +0000 (06:48 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 24 Apr 2002 10:48:44 +0000 (06:48 -0400)
        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

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/cp/typeck.c
gcc/testsuite/g++.dg/init/array3.C [new file with mode: 0644]

index 971d0bd63f51858a256931d54efd7a2f46f3ff50..0b946576fef20fe9af1c51f301024880a56de373 100644 (file)
@@ -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.
index 830771e4267eb86a6aa6d791540fc7cd9ee30f17..efcd5fb289a36758e705df0096bd621fb6d84ddb 100644 (file)
@@ -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);
 
index 690df764bf58e7992298d84fe8e286e2736f847f..10db2f84b3a0c2136e4603d04c79bac779060dc7 100644 (file)
@@ -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 (file)
index 0000000..700b263
--- /dev/null
@@ -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());
+}
This page took 0.105088 seconds and 5 git commands to generate.