Commit 0a9696f0 by Paolo Carlini Committed by Paolo Carlini

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
parent 9c09f152
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
......
......@@ -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);
......
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.
......
// 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" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment