* init.c (build_new_1): Don't strip quals from type.
authorJason Merrill <jason@redhat.com>
Fri, 15 Dec 2000 16:23:26 +0000 (11:23 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 15 Dec 2000 16:23:26 +0000 (11:23 -0500)
From-SVN: r38291

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/g++.old-deja/g++.other/new5.C [new file with mode: 0644]

index 3143094f058d419356a803d278666cccff48ba00..d92e24e1fd4fffc94c6c5051e360eaf865dabde6 100644 (file)
@@ -1,5 +1,7 @@
 2000-12-15  Jason Merrill  <jason@redhat.com>
 
+       * init.c (build_new_1): Don't strip quals from type.
+
        * decl.c (pushdecl): Don't check for linkage on a non-decl.
 
        * call.c (build_op_delete_call): See through ARRAY_TYPEs.
index a9360e52723c8045ca9c6213c2c17c4d0ec3e747..7a2ce18970495fac8d6004122d210bf5e8c5b020 100644 (file)
@@ -2268,9 +2268,6 @@ build_new_1 (exp)
 
   code = has_array ? VEC_NEW_EXPR : NEW_EXPR;
 
-  if (CP_TYPE_QUALS (type))
-    type = TYPE_MAIN_VARIANT (type);
-
   /* If our base type is an array, then make sure we know how many elements
      it has.  */
   while (TREE_CODE (true_type) == ARRAY_TYPE)
diff --git a/gcc/testsuite/g++.old-deja/g++.other/new5.C b/gcc/testsuite/g++.old-deja/g++.other/new5.C
new file mode 100644 (file)
index 0000000..99f3b07
--- /dev/null
@@ -0,0 +1,12 @@
+// Test that const-correctness is observed when using new.
+
+struct A {
+  A() { }
+  int f () { return 1; }
+  int f () const { return 0; }
+};
+
+int main ()
+{
+  return (new const A)->f ();
+}