summaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-03 09:51:39 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-03 09:51:39 +0000
commit7653c32a8b57d088995b60a784c822a1aacf308e (patch)
treec21f55ff3fc59c4b4156189cb31525a6dc08b3e1 /gcc/cp/init.c
parente6d1500f9c8e1eddf4ba10b7fe3d809b87fd0200 (diff)
downloadgcc-7653c32a8b57d088995b60a784c822a1aacf308e.tar.gz
cp:
PR c++/18318 * parser.c (cp_parser_new_type_id): Move array size expression checks from here ... * init.c (build_new): ... to here. testsuite: PR c++/18318 * g++.dg/template/new1.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91678 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 9d00d4b6a46..7dd15d2e1df 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1633,6 +1633,15 @@ build_new (tree placement, tree type, tree nelts, tree init,
return rval;
}
+ if (nelts)
+ {
+ if (!build_expr_type_conversion (WANT_INT | WANT_ENUM, nelts, false))
+ pedwarn ("size in array new must have integral type");
+ nelts = save_expr (cp_convert (sizetype, nelts));
+ if (nelts == integer_zero_node)
+ warning ("zero size array reserves no space");
+ }
+
/* ``A reference cannot be created by the new operator. A reference
is not an object (8.2.2, 8.4.3), so a pointer to it could not be
returned by new.'' ARM 5.3.3 */