From 8d42565b847d588e6c04e9c3cd5a3157859e2c6a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 15 Dec 2000 11:23:26 -0500 Subject: [PATCH] * init.c (build_new_1): Don't strip quals from type. From-SVN: r38291 --- gcc/cp/ChangeLog | 2 ++ gcc/cp/init.c | 3 --- gcc/testsuite/g++.old-deja/g++.other/new5.C | 12 ++++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/new5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3143094f058..d92e24e1fd4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2000-12-15 Jason Merrill + * 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. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index a9360e52723..7a2ce189704 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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 index 00000000000..99f3b076fe0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new5.C @@ -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 (); +} -- 2.30.2