* g++.dg/lookup/java1.C: Update for chage of
[official-gcc.git] / gcc / testsuite / g++.dg / lookup / java1.C
blob270910d1daa4041a135df62de3ba22b2f593cbf2
1 // { dg-do compile }\r
2 // { dg-options "-fdollars-in-identifiers" }\r
3 // Origin: Giovanni Bajo <giovannibajo at libero dot it>\r
4 // Make sure that Java special functions can be called correctly.\r
5 \r
6 extern "Java"\r
7 {\r
8   typedef __java_int jint;\r
9   namespace java\r
10   {\r
11     namespace lang\r
12     {\r
13       class Class;\r
14       class Object;\r
15       class Throwable {};\r
16       class Foo;\r
17     }\r
18   }\r
19 }\r
21 typedef struct java::lang::Object* jobject;\r
22 typedef struct java::lang::Throwable* jthrowable;\r
23 typedef class java::lang::Class* jclass;\r
24 using java::lang::Foo;\r
26 class Foo : public java::lang::Throwable\r
27 {\r
28 public:\r
29   static ::java::lang::Class class$;\r
30 };\r
33 /*\r
34  * Step 1: no declarations. A declaration for _Jv_Throw is created.\r
35  */\r
37 void Bar1(void)\r
38 {\r
39   Foo* f = new java::lang::Foo;   // { dg-error "call to Java constructor" }\r
40   throw (f);\r
41 }\r
44 /*\r
45  * Step 2: constructor declaration\r
46  */\r
48 extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));\r
50 void Bar2(void)\r
51 {\r
52   Foo* f = new java::lang::Foo; \r
53   throw (f);  \r
54 }\r
57 /*\r
58  * Step 3: overloads\r
59  */\r
61 jobject _Jv_AllocObject (jclass, jint, float) __attribute__((__malloc__));\r
62 void _Jv_Throw (int, float) __attribute__ ((__noreturn__));\r
64 void Bar3(void)\r
65 {\r
66   Foo* f = new java::lang::Foo;   // { dg-error "should never be overloaded" }\r
67   throw (f);                      // { dg-error "should never be overloaded" }\r
68 }\r