This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Enforce extern "Java" aggregates to be heap allocated (PR c++/30293, c++/30294)


Jakub Jelinek writes:
 > Hi!
 > 
 > gcj.texi says:
 > 
 > All of the listed attributes are also true of C++, though C++ has
 > extra features (for example in C++ objects may be allocated not just
 > on the heap, but also statically or in a local stack frame).
 > 
 > There is a couple of ICEs where invalid code defines extern "Java"
 > aggregates with initializers or returns them from a function.
 > 
 > Tom suggested in the bugzilla that we should enforce that extern "Java"
 > objects are always heap allocated and the following patch does that
 > and cures the ICEs at the same time.
 > 
 > The only exception I had to make is for libjava/prims.cc where we have:
 > // Ensure 8-byte alignment, for hash synchronization.
 > #define DECLARE_PRIM_TYPE(NAME)                 \
 >   java::lang::Class _Jv_##NAME##Class __attribute__ ((aligned (8)));
 > 
 > DECLARE_PRIM_TYPE(byte)
 > DECLARE_PRIM_TYPE(short)
 > DECLARE_PRIM_TYPE(int)
 > DECLARE_PRIM_TYPE(long)
 > DECLARE_PRIM_TYPE(boolean)
 > DECLARE_PRIM_TYPE(char)
 > DECLARE_PRIM_TYPE(float)
 > DECLARE_PRIM_TYPE(double)
 > DECLARE_PRIM_TYPE(void)
 > 
 > which at least don't have any initializer and thus shouldn't cause ICEs.
 > Even then I limited this exception for __typeof (*jclass) objects without
 > initializers only.
 > 
 > The testcase shows what is and is not allowed.
 > 
 > Bootstrapped/regtested on x86_64-linux, ok for trunk?
 > 
 > 2007-11-22  Jakub Jelinek  <jakub@redhat.com>
 > 
 > 	PR c++/30293
 > 	PR c++/30294
 > 	* decl.c (cp_finish_decl): Disallow variable or field
 > 	definitions if extern "Java" aggregates.
 > 	(grokparms): Disallow parameters with extern "Java"
 > 	aggregates.
 > 	(check_function_type): Disallow function return values
 > 	with extern "Java" aggregates.
 > 	* init.c (build_new_1): Disallow placement new with
 > 	extern "Java" aggregates.
 > 
 > 	* g++.dg/ext/java-2.C: New test.

OK from me.

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]