/* Handle initialization things in C++.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
(alloc_fn,
build_tree_list (NULL_TREE, class_addr)));
}
- else if (TYPE_FOR_JAVA (elt_type))
+ else if (TYPE_FOR_JAVA (elt_type) && IS_AGGR_TYPE (elt_type))
{
error ("Java class %q#T object allocated using placement new", elt_type);
return error_mark_node;
--- /dev/null
+// Test for PR c++/34829
+// Placement new should be ok for non-aggregate Java types.
+
+// { dg-do compile }
+// { dg-options "" }
+
+extern "Java"
+{
+ typedef __java_byte jbyte;
+}
+
+void *operator new (unsigned int s, void *m)
+{
+ return m;
+}
+
+jbyte *f(void *memory)
+{
+ return new (memory) jbyte;
+}