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
2004-12-02 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/18318
+ * parser.c (cp_parser_new_type_id): Move array size expression
+ checks from here ...
+ * init.c (build_new): ... to here.
+
+2004-12-02 Nathan Sidwell <nathan@codesourcery.com>
+
PR c++/18758
* parser.c (cp_parser_class_head): Return NULL_TREE when
push_template_decl fails. Update comment.
2004-12-01 Matt Austern <austern@apple.com>
- * name-lookup.c (namespace_binding): Omit alias check for global namespace.
+ * name-lookup.c (namespace_binding): Omit alias check for global
+ namespace.
2004-12-01 Nathan Sidwell <nathan@codesourcery.com>
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 */
*nelts = declarator->u.array.bounds;
if (*nelts == error_mark_node)
*nelts = integer_one_node;
- else if (!processing_template_decl)
- {
- 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");
- }
+
if (outer_declarator)
outer_declarator->declarator = declarator->declarator;
else
+2004-12-03 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/18318
+ * g++.dg/template/new1.C: New.
+
2004-12-02 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/18710
--- /dev/null
+// { dg-do run }
+// { dg-options "-O2" }
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 2 Dec 2004 <nathan@codesourcery.com>
+
+// PR 18318. ICE with template new[]
+// Origin:Elliot Hughes <enh@jessies.org>
+// Andrew Pinski <pinskia@gcc.gnu.org>
+
+struct Aint
+{
+ ~Aint ();
+ Aint ();
+};
+
+Aint::Aint () {}
+Aint::~Aint () {}
+
+static int count;
+
+template <class T>
+struct A
+{
+ unsigned Blksize() const;
+
+ void f()
+ {
+ new T[Blksize()];
+ }
+};
+
+template <class T> unsigned A<T>::Blksize () const
+{
+ count++;
+ return 1;
+}
+
+int main ()
+{
+ A<Aint> a;
+ a.f();
+
+ return count != 1;
+}