aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-05-23 14:19:27 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-05-23 14:19:27 +0000
commit0a9696f0225d1ab4a8d3a992c9e98f68e9996876 (patch)
treebc5bfada5b01bc7295cda02728be8d6d6be43c9e /gcc
parent9c09f152d90089509bcc4b5b8094fbbb1707fbc1 (diff)
downloadgcc-0a9696f0225d1ab4a8d3a992c9e98f68e9996876.zip
gcc-0a9696f0225d1ab4a8d3a992c9e98f68e9996876.tar.gz
gcc-0a9696f0225d1ab4a8d3a992c9e98f68e9996876.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/warn/delete-array-1.C11
4 files changed, 24 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 391407f..c3d9841 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index c40b830..bf9ca33 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4934bd2..35dd366 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/warn/delete-array-1.C b/gcc/testsuite/g++.dg/warn/delete-array-1.C
new file mode 100644
index 0000000..c3af713
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/delete-array-1.C
@@ -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" }
+}