re PR c++/34829 (placement new with primitive Java types rejected)

gcc/testsuite
	PR c++/34829:
	* g++.dg/ext/pr34829.C: New file.
gcc/cp
	PR c++/34829:
	* init.c (build_new_1): Only disallow Java aggregates.

From-SVN: r131732
This commit is contained in:
Tom Tromey 2008-01-22 17:54:59 +00:00 committed by Tom Tromey
parent c316155b7f
commit 255ef0345c
4 changed files with 32 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2008-01-22 Tom Tromey <tromey@redhat.com>
PR c++/34829:
* init.c (build_new_1): Only disallow Java aggregates.
2008-01-22 Jakub Jelinek <jakub@redhat.com>
PR c++/34607

View file

@ -1,6 +1,6 @@
/* 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)
@ -1786,7 +1786,7 @@ build_new_1 (tree placement, tree type, tree nelts, tree init,
(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;

View file

@ -1,3 +1,8 @@
2008-01-22 Tom Tromey <tromey@redhat.com>
PR c++/34829:
* g++.dg/ext/pr34829.C: New file.
2008-01-22 Jakub Jelinek <jakub@redhat.com>
PR c++/34607

View file

@ -0,0 +1,20 @@
// 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;
}