OSDN Git Service

* init.c (build_new_1): Don't strip quals from type.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Dec 2000 16:23:26 +0000 (16:23 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Dec 2000 16:23:26 +0000 (16:23 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38291 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 3143094..d92e24e 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 a9360e5..7a2ce18 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 ();
+}