For gcc/cp/ChangeLog: * decl2.c (delete_sanity): check for a pointer type on delete[] too. For gcc/testsuite/ChangeLog: * gcc/testsuite/g++.old-deja/g++.other/delete2.C: test for errors when deleting array types and expect failures when deleting class types. Index: gcc/cp/decl2.c =================================================================== RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v retrieving revision 1.79 diff -u -u -r1.79 decl2.c --- gcc/cp/decl2.c 1998/05/29 02:33:51 1.79 +++ gcc/cp/decl2.c 1998/06/07 20:24:14 @@ -1266,10 +1266,21 @@ pedwarn ("anachronistic use of array size in vector delete"); /* Fall through. */ case 1: + if (code != POINTER_TYPE) + { + /* FIXME: We should also accept class types, and check for + conversion operators to pointer types. */ + cp_error ("type `%#T' argument given to `delete[]', expected pointer", + type); + return error_mark_node; + } + break; default: if (code != POINTER_TYPE) { + /* FIXME: We should also accept class types, and check for + conversion operators to pointer types. */ cp_error ("type `%#T' argument given to `delete', expected pointer", type); return error_mark_node; --- /dev/null Sat Jun 6 17:07:31 1998 +++ gcc/testsuite/g++.old-deja/g++.other/delete2.C Sun Jun 7 17:12:41 1998 @@ -0,0 +1,13 @@ +// Build don't link: + +struct foo { + operator char*() const; +}; + +void bar(foo a) { + delete a; // should be accepted - XFAIL *-*-* + delete[] a; // should be accepted - XFAIL *-*-* + char b[1]; + delete b; // ERROR - expecting pointer type + delete[] b; // ERROR - expecting pointer type +}