class.c (add_method): Disallow destructor for java classes.
cp: * class.c (add_method): Disallow destructor for java classes. * decl.c (xref_basetypes): Check java class inheritance. * decl2.c (check_java_method): Skip artificial params. testsuite: * g++.dg/other/java1.C: New test. From-SVN: r74629
This commit is contained in:
parent
5fd80fbc3b
commit
f5c28a158b
@ -1,5 +1,9 @@
|
||||
2003-12-15 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* class.c (add_method): Disallow destructor for java classes.
|
||||
* decl.c (xref_basetypes): Check java class inheritance.
|
||||
* decl2.c (check_java_method): Skip artificial params.
|
||||
|
||||
PR c++/13241
|
||||
C++ ABI change. Mangling of symbols in expressions.
|
||||
* mangle.c (write_mangled_name): Add top_level flag. Rework for
|
||||
|
@ -755,6 +755,12 @@ add_method (tree type, tree method, int error_p)
|
||||
{
|
||||
slot = CLASSTYPE_DESTRUCTOR_SLOT;
|
||||
TYPE_HAS_DESTRUCTOR (type) = 1;
|
||||
|
||||
if (TYPE_FOR_JAVA (type))
|
||||
error (DECL_ARTIFICIAL (method)
|
||||
? "Java class '%T' cannot have an implicit non-trivial destructor"
|
||||
: "Java class '%T' cannot have a destructor",
|
||||
DECL_CONTEXT (method));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -9625,7 +9625,15 @@ xref_basetypes (tree ref, tree base_list)
|
||||
inheritance order chain. */
|
||||
copy_base_binfos (TYPE_BINFO (ref), ref, NULL_TREE);
|
||||
CLASSTYPE_VBASECLASSES (ref) = nreverse (CLASSTYPE_VBASECLASSES (ref));
|
||||
|
||||
|
||||
if (TYPE_FOR_JAVA (ref))
|
||||
{
|
||||
if (TYPE_USES_MULTIPLE_INHERITANCE (ref))
|
||||
error ("Java class '%T' cannot have multiple bases", ref);
|
||||
if (CLASSTYPE_VBASECLASSES (ref))
|
||||
error ("Java class '%T' cannot have virtual bases", ref);
|
||||
}
|
||||
|
||||
/* Unmark all the types. */
|
||||
while (i--)
|
||||
{
|
||||
|
@ -622,12 +622,20 @@ check_java_method (tree method)
|
||||
bool jerr = false;
|
||||
tree arg_types = TYPE_ARG_TYPES (TREE_TYPE (method));
|
||||
tree ret_type = TREE_TYPE (TREE_TYPE (method));
|
||||
|
||||
if (!acceptable_java_type (ret_type))
|
||||
{
|
||||
error ("Java method '%D' has non-Java return type `%T'",
|
||||
method, ret_type);
|
||||
jerr = true;
|
||||
}
|
||||
|
||||
arg_types = TREE_CHAIN (arg_types);
|
||||
if (DECL_HAS_IN_CHARGE_PARM_P (method))
|
||||
arg_types = TREE_CHAIN (arg_types);
|
||||
if (DECL_HAS_VTT_PARM_P (method))
|
||||
arg_types = TREE_CHAIN (arg_types);
|
||||
|
||||
for (; arg_types != NULL_TREE; arg_types = TREE_CHAIN (arg_types))
|
||||
{
|
||||
tree type = TREE_VALUE (arg_types);
|
||||
|
@ -1,5 +1,7 @@
|
||||
2003-12-15 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* g++.dg/other/java1.C: New test.
|
||||
|
||||
PR c++/13241
|
||||
* g++.dg/abi/mangle18-1.C: New test.
|
||||
* g++.dg/abi/mangle18-2.C: New test.
|
||||
|
22
gcc/testsuite/g++.dg/other/java1.C
Normal file
22
gcc/testsuite/g++.dg/other/java1.C
Normal file
@ -0,0 +1,22 @@
|
||||
// { dg-options "-w -ansi -pedantic" }
|
||||
|
||||
// Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 23 Oct 2003 <nathan@codesourcery.com>
|
||||
|
||||
extern "Java" {
|
||||
class One
|
||||
{
|
||||
~One (); // { dg-error "cannot have a destructor" "" }
|
||||
One ();
|
||||
};
|
||||
|
||||
class Two {};
|
||||
|
||||
class Three : One {}; // { dg-error "cannot have an implicit" "" }
|
||||
|
||||
class Four : Two {};
|
||||
|
||||
class Five : Two, Four {}; // { dg-error "cannot have multiple bases" "" }
|
||||
|
||||
class Six : virtual Two {}; // { dg-error "cannot have virtual base" "" }
|
||||
}
|
Loading…
Reference in New Issue
Block a user