aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-12-15 14:19:10 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2003-12-15 14:19:10 +0000
commitf5c28a158bb972bef91b18028e1965722b5cff69 (patch)
tree3c9cdd851e654dd096ba9dadc263e8e0fd0f80fb /gcc
parent5fd80fbc3ba36fba8c0ec6c0f8509ff44e0a9fdd (diff)
downloadgcc-f5c28a158bb972bef91b18028e1965722b5cff69.zip
gcc-f5c28a158bb972bef91b18028e1965722b5cff69.tar.gz
gcc-f5c28a158bb972bef91b18028e1965722b5cff69.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/class.c6
-rw-r--r--gcc/cp/decl.c10
-rw-r--r--gcc/cp/decl2.c8
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/other/java1.C22
6 files changed, 51 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5d70a54..93a3719 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 2da8f8d..55e9797 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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
{
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 539bf19..1eafe2e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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--)
{
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b7774c4..14814b5 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2d2d7cc..675122e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/other/java1.C b/gcc/testsuite/g++.dg/other/java1.C
new file mode 100644
index 0000000..38b5e0c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/java1.C
@@ -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" "" }
+}