summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-04 00:21:33 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-04 00:21:33 +0000
commitdcf091d4dcbc539317cc253657587931580e93ab (patch)
tree8c59baf94a71413e1d59612c1d7bbe72c890bd64 /gcc
parentf3f9757d0c619dfe5bc52064e373157a54b8fc69 (diff)
downloadgcc-dcf091d4dcbc539317cc253657587931580e93ab.tar.gz
PR c++/31743
* parser.c (cp_parser_new_type_id): Don't reduce a named array type to its base type and number of elements here. * init.c (build_new): Call complete_type_or_else to ensure that the type is complete and to issue a diagnostic if it is not. (build_new_1): Don't call complete_type_or_else here. PR c++/31743 * g++.dg/init/new20.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126292 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/init.c7
-rw-r--r--gcc/cp/parser.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rwxr-xr-xgcc/testsuite/g++.dg/init/new20.C6
5 files changed, 24 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 059631f2e3e..7316fbf0c41 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-29 Dave Brolley <brolley@redhat.com>
+
+ PR c++/31743
+ * parser.c (cp_parser_new_type_id): Don't reduce a named array
+ type to its base type and number of elements here.
+ * init.c (build_new): Call complete_type_or_else to ensure that the
+ type is complete and to issue a diagnostic if it is not.
+ (build_new_1): Don't call complete_type_or_else here.
+
2007-07-03 Richard Guenther <rguenther@suse.de>
PR c++/32609
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 3eb6d5d97a9..1647bc005ac 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1705,9 +1705,6 @@ build_new_1 (tree placement, tree type, tree nelts, tree init,
}
}
- if (!complete_type_or_else (type, NULL_TREE))
- return error_mark_node;
-
/* If our base type is an array, then make sure we know how many elements
it has. */
for (elt_type = type;
@@ -2210,6 +2207,10 @@ build_new (tree placement, tree type, tree nelts, tree init,
return error_mark_node;
}
+ /* PR 31743: Make sure the array type has a known size. */
+ if (!complete_type_or_else (type, NULL_TREE))
+ return error_mark_node;
+
rval = build_new_1 (placement, type, nelts, init, use_global_new);
if (rval == error_mark_node)
return error_mark_node;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d6e62045dd2..ae970d68da8 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -5521,11 +5521,6 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts)
}
type = groktypename (&type_specifier_seq, new_declarator);
- if (TREE_CODE (type) == ARRAY_TYPE && *nelts == NULL_TREE)
- {
- *nelts = array_type_nelts_top (type);
- type = TREE_TYPE (type);
- }
return type;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fc5dca36f8c..97d5e2bf4e8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-06-29 Dave Brolley <brolley@redhat.com>
+
+ PR c++/31743
+ * g++.dg/init/new20.C: New test.
+
2007-07-03 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/32579
diff --git a/gcc/testsuite/g++.dg/init/new20.C b/gcc/testsuite/g++.dg/init/new20.C
new file mode 100755
index 00000000000..705c1be482f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/new20.C
@@ -0,0 +1,6 @@
+// PR c++/31743
+typedef int A[];
+A* p = new A; // { dg-error "invalid use of array with unspecified bounds" }
+A* q = new (A); // { dg-error "invalid use of array with unspecified bounds" }
+
+