blob: af5495915916dcc993ab855bf1b16e4d7bd948cd (
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
|
// Special g++ Options: -fhandle-signatures
// GROUPS passed gb sigptr this
// Test passing of 'this' pointer through signature pointer.
extern "C"
{
int printf (char *, ...);
}
class C;
int inc_mod_4 (C *);
class C
{
public:
char * text[4];
int i;
int get_i (void) { return i; }
char * msg (void) { i = inc_mod_4 (this); return text[i]; }
};
signature S
{
char * msg (void);
};
int inc_mod_4 (C * p)
{
return (p->get_i () + 1) % 4;
}
int main (void)
{
C o = { "P", "A", "S", "S", -1 };
S * p;
int i;
p = &o;
for (i = 0; i < 4; i++)
printf ("%s", p->msg ());
printf ("\n");
return 0;
}
|