summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/lookup/java1.C
blob: 0d9b22ee1d55811361a56bd67fb93e6b35b353cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// { dg-do compile }
// { dg-options "-fdollars-in-identifiers" }
// Origin: Giovanni Bajo <giovannibajo at libero dot it>
// Make sure that Java special functions can be called correctly.

extern "Java"
{
  typedef __java_int jint;
  namespace java
  {
    namespace lang
    {
      class Class;
      class Object;
      class Throwable {};
      class Foo;
    }
  }
}

typedef struct java::lang::Object* jobject;
typedef struct java::lang::Throwable* jthrowable;
typedef class java::lang::Class* jclass;
using java::lang::Foo;

class Foo : public java::lang::Throwable
{
public:
  static ::java::lang::Class class$;
};


/*
 * Step 1: no declarations. A declaration for _Jv_Throw is created.
 */

void Bar1(void)
{
  Foo* f = new java::lang::Foo;   // { dg-error "call to Java constructor" }
  throw (f);
}


/*
 * Step 2: constructor declaration
 */

extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));

void Bar2(void)
{
  Foo* f = new java::lang::Foo; 
  throw (f);  
}


/*
 * Step 3: overloads
 */

jobject _Jv_AllocObject (jclass, jint, float) __attribute__((__malloc__));
void _Jv_Throw (int, float) __attribute__ ((__noreturn__));

void Bar3(void)
{
  Foo* f = new java::lang::Foo;	  // { dg-error "should never be overloaded" }
  throw (f);			  // { dg-error "should never be overloaded" }
}