+2003-12-07 Giovanni Bajo <giovannibajo@gcc.gnu.org>\r
+\r
+ * g++.dg/lookup/java1.C: New test.\r
+ * g++.dg/lookup/java2.C: New test.\r
+
2003-12-07 Falk Hueffner <falk@debian.org>
* g++.dg/opt/noreturn-1.C: New test.
--- /dev/null
+// { dg-do compile }\r
+// { dg-options "" }\r
+// Origin: Giovanni Bajo <giovannibajo at libero dot it>\r
+// Make sure that Java special functions can be called correctly.\r
+\r
+extern "Java"\r
+{\r
+ typedef __java_int jint;\r
+ namespace java\r
+ {\r
+ namespace lang\r
+ {\r
+ class Class;\r
+ class Object;\r
+ class Throwable {};\r
+ class Foo;\r
+ }\r
+ }\r
+}\r
+\r
+typedef struct java::lang::Object* jobject;\r
+typedef struct java::lang::Throwable* jthrowable;\r
+typedef class java::lang::Class* jclass;\r
+using java::lang::Foo;\r
+\r
+class Foo : public java::lang::Throwable\r
+{\r
+public:\r
+ static ::java::lang::Class class$;\r
+};\r
+\r
+\r
+/*\r
+ * Step 1: no declarations. A declaration for _Jv_Throw is created.\r
+ */\r
+\r
+void Bar1(void)\r
+{\r
+ Foo* f = new java::lang::Foo; // { dg-error "call to Java constructor" }\r
+ throw (f);\r
+}\r
+\r
+\r
+/*\r
+ * Step 2: constructor declaration\r
+ */\r
+\r
+extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__));\r
+\r
+void Bar2(void)\r
+{\r
+ Foo* f = new java::lang::Foo; \r
+ throw (f); \r
+}\r
+\r
+\r
+/*\r
+ * Step 3: overloads\r
+ */\r
+\r
+jobject _Jv_AllocObject (jclass, jint, float) __attribute__((__malloc__));\r
+void _Jv_Throw (int, float) __attribute__ ((__noreturn__));\r
+\r
+void Bar3(void)\r
+{\r
+ Foo* f = new java::lang::Foo; // { dg-error "should never be overloaded" }\r
+ throw (f); // { dg-error "should never be overloaded" }\r
+}\r
--- /dev/null
+// { dg-do compile }\r
+// { dg-options "" }\r
+// Origin: Giovanni Bajo <giovannibajo at libero dot it>\r
+// Make sure that Java special functions can be called correctly.\r
+// (continue from java1.C)\r
+\r
+extern "Java"\r
+{\r
+ typedef __java_int jint;\r
+ namespace java\r
+ {\r
+ namespace lang\r
+ {\r
+ class Class;\r
+ class Object;\r
+ class Throwable {};\r
+ class Foo;\r
+ }\r
+ }\r
+}\r
+\r
+typedef struct java::lang::Object* jobject;\r
+typedef struct java::lang::Throwable* jthrowable;\r
+typedef class java::lang::Class* jclass;\r
+using java::lang::Foo;\r
+\r
+class Foo : public java::lang::Throwable\r
+{\r
+public:\r
+ static ::java::lang::Class class$;\r
+};\r
+\r
+/*\r
+ * Step 4: Manual declaration of _Jv_Throw\r
+ * This is the last case we need to test. In the other file we're testing\r
+ * the compiler is able to generate an artifical declaration for this \r
+ * function, so we need to test here if it works with a normal declaration.\r
+ */\r
+\r
+extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__));\r
+extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));\r
+\r
+void Bar4(void)\r
+{\r
+ Foo* f = new java::lang::Foo;\r
+ throw (f);\r
+}\r