re PR c++/29185 (inconsistent warning: deleting array)

/cp
2012-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/29185
	* decl2.c (delete_sanity): Extend 'deleting array' warning to
	any array type.

/testsuite
2012-05-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/29185
	* g++.dg/warn/delete-array-1.C: New.

From-SVN: r187801
This commit is contained in:
Paolo Carlini 2012-05-23 14:19:27 +00:00 committed by Paolo Carlini
parent 9c09f152d9
commit 0a9696f022
4 changed files with 24 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2012-05-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/29185
* decl2.c (delete_sanity): Extend 'deleting array' warning to
any array type.
2012-05-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51184

View File

@ -438,9 +438,8 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete,
}
/* An array can't have been allocated by new, so complain. */
if (TREE_CODE (exp) == VAR_DECL
&& TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
warning (0, "deleting array %q#D", exp);
if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
warning (0, "deleting array %q#E", exp);
t = build_expr_type_conversion (WANT_POINTER, exp, true);

View File

@ -1,3 +1,8 @@
2012-05-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/29185
* g++.dg/warn/delete-array-1.C: New.
2012-05-23 Richard Guenther <rguenther@suse.de>
* gcc.dg/torture/pr39074-2.c: Adjust.

View File

@ -0,0 +1,11 @@
// PR c++/29185
int a [1];
struct S { int a [1]; } s;
void foo (S *p)
{
delete a; // { dg-warning "deleting array" }
delete s.a; // { dg-warning "deleting array" }
delete p->a; // { dg-warning "deleting array" }
}