summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/java-2.C
blob: 8114517b942c685af0b57e3bfe7af02828c0ff8b (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
69
70
71
72
73
74
75
76
77
78
79
// PR c++/30293
// PR c++/30294
// { dg-do compile { target { ! { powerpc-ibm-aix* } } } }
// { dg-options "" }

extern "Java" {
typedef __java_byte jbyte;
namespace java {
namespace lang {
  class Object {};
  class Class {};
}
}
typedef struct java::lang::Object* jobject;
typedef java::lang::Class *jclass;
}
extern "C" jobject _Jv_AllocObject (jclass);

extern "Java" {
  struct A { static java::lang::Class class$; };
}

struct B {
  A a;		// { dg-error "has Java class type" }
};

void* operator new (__SIZE_TYPE__, void*) throw();
char buf[1024];

A a;		// { dg-error "not allocated with" }
A b = A ();	// { dg-error "not allocated with" }
A *c = new ((void *) buf) A ();	// { dg-error "using placement new" }
A *d = new A ();
jbyte e = 6;

const A fn1 ()	// { dg-error "return type has Java class type" }
{
  A a;		// { dg-error "not allocated with" }
  return a;
}

A fn2 ()	// { dg-error "return type has Java class type" }
{
  A a;		// { dg-error "not allocated with" }
  return a;
}

A *fn3 ()
{
  return new A ();
}

A &fn4 ()
{
  return *c;
}

jbyte fn5 ()
{
  return 7;
}

void fn6 (A x)	// { dg-error "has Java class type" }
{
}

void fn7 (const A x)	// { dg-error "has Java class type" }
{
}

void fn8 (A *x)
{
  (void) x;
}

void fn9 (jbyte x)
{
  (void) x;
}