aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@gcc.gnu.org>2006-09-07 19:49:11 -0700
committerAndrew Pinski <pinskia@gcc.gnu.org>2006-09-07 19:49:11 -0700
commit158d56c4e2ce2ae5f3044bd7a277fef43466f2f6 (patch)
tree3a3d650f1d3ba0ceb1866a66d52764d7858dbcb9 /gcc
parentd0655f33aa551fddb74b0d8c591b0f58468b8527 (diff)
downloadgcc-158d56c4e2ce2ae5f3044bd7a277fef43466f2f6.zip
gcc-158d56c4e2ce2ae5f3044bd7a277fef43466f2f6.tar.gz
gcc-158d56c4e2ce2ae5f3044bd7a277fef43466f2f6.tar.bz2
006-09-07 Andrew Pinski <pinskia@physics.uc.edu>
PR C++/28906 * init.c (build_new_1): Build a distinct type copy for the array type that was returned from build_cplus_array_type. 2006-09-07 Andrew Pinski <pinskia@physics.uc.edu> PR C++/28906 * g++.dg/other/array3.C: New test. * g++.dg/other/array4.C: New test. * g++.dg/other/array5.C: New test. From-SVN: r116776
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/init.c8
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/other/array3.C14
-rw-r--r--gcc/testsuite/g++.dg/other/array4.C19
-rw-r--r--gcc/testsuite/g++.dg/other/array5.C9
6 files changed, 64 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5467464..a914e2a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-07 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR C++/28906
+ * init.c (build_new_1): Build a distinct type copy
+ for the array type that was returned from
+ build_cplus_array_type.
+
2006-09-07 Jason Merrill <jason@redhat.com>
PR c++/27371
@@ -15,7 +22,7 @@
2006-09-06 Zak Kipling <zak@transversal.com>
- PR c++/26195
+ PR c++/26195
* decl.c (make_rtl_for_nonlocal_decl),
(start_preparsed_function): Don't use lbasename on
input_filename when calling get_fileinfo.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index a88d0c0..ad40736 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1628,10 +1628,14 @@ build_new_1 (tree placement, tree type, tree nelts, tree init,
function context. Methinks that's not it's purvey. So we'll do
our own VLA layout later. */
vla_p = true;
- full_type = build_cplus_array_type (type, NULL_TREE);
index = convert (sizetype, nelts);
index = size_binop (MINUS_EXPR, index, size_one_node);
- TYPE_DOMAIN (full_type) = build_index_type (index);
+ index = build_index_type (index);
+ full_type = build_cplus_array_type (type, NULL_TREE);
+ /* We need a copy of the type as build_array_type will return a shared copy
+ of the incomplete array type. */
+ full_type = build_distinct_type_copy (full_type);
+ TYPE_DOMAIN (full_type) = index;
}
else
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7c38ebc..2ec550f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-07 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR C++/28906
+ * g++.dg/other/array3.C: New test.
+ * g++.dg/other/array4.C: New test.
+ * g++.dg/other/array5.C: New test.
+
2006-09-07 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/pr28946.c (dg-options): Use -Os instead -O.
@@ -11,7 +18,7 @@
* gfortran.fortran-torture/compile/data_1.f90: Fix integer oveflow
in integer literal constant.
- * gfortran.dg/enum_8.f90: Ditto.
+ * gfortran.dg/enum_8.f90: Ditto.
* gfortran.dg/g77/20030326-1.f: Ditto.
2006-09-07 Feng Wang <fengwang@nudt.edu.cn>
diff --git a/gcc/testsuite/g++.dg/other/array3.C b/gcc/testsuite/g++.dg/other/array3.C
new file mode 100644
index 0000000..ce3641e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/array3.C
@@ -0,0 +1,14 @@
+// PR C++/28906: new on an array causes incomplete arrays to
+// become complete with the wrong size.
+
+// the bounds of xvalue_store was being set to include want
+// which was incorrect.
+
+// { dg-do compile }
+
+extern unsigned char xvalue_store[];
+bool reserve (int want)
+{
+ new unsigned char[want];
+}
+unsigned char xvalue_store[257];
diff --git a/gcc/testsuite/g++.dg/other/array4.C b/gcc/testsuite/g++.dg/other/array4.C
new file mode 100644
index 0000000..97ccc98
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/array4.C
@@ -0,0 +1,19 @@
+// PR C++/28906: new on an array causes incomplete arrays to
+// become complete with the wrong size.
+// The sizeof machineMain should be 5 and not 100.
+// { dg-do run }
+
+
+extern char machineMain[];
+void sort (long len)
+{
+ new char[100];
+}
+char machineMain[] = "main";
+int main(void)
+{
+ if (sizeof(machineMain)!=sizeof("main"))
+ __builtin_abort();
+}
+
+
diff --git a/gcc/testsuite/g++.dg/other/array5.C b/gcc/testsuite/g++.dg/other/array5.C
new file mode 100644
index 0000000..df551e3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/array5.C
@@ -0,0 +1,9 @@
+// Check to make sure changing from an incomplete
+// array type to a complete one does not change other
+// incomplete array type's bounds.
+// { dg-do compile }
+
+extern unsigned char xvalue_store[];
+extern unsigned char xvalue_store1[];
+unsigned char xvalue_store[7];
+unsigned char xvalue_store1[9];