* g++.dg/lookup/java1.C: New test.
authorgiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Dec 2003 15:26:05 +0000 (15:26 +0000)
committergiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Dec 2003 15:26:05 +0000 (15:26 +0000)
* g++.dg/lookup/java2.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74395 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/java1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lookup/java2.C [new file with mode: 0644]

index 558f7a4..09784c0 100644 (file)
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/testsuite/g++.dg/lookup/java1.C b/gcc/testsuite/g++.dg/lookup/java1.C
new file mode 100644 (file)
index 0000000..550ff59
--- /dev/null
@@ -0,0 +1,68 @@
+// { 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
diff --git a/gcc/testsuite/g++.dg/lookup/java2.C b/gcc/testsuite/g++.dg/lookup/java2.C
new file mode 100644 (file)
index 0000000..6c78715
--- /dev/null
@@ -0,0 +1,47 @@
+// { 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