blob: 975b6c828e3f26e0ed2af2cb265af73a20bc860f (
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
|
// { dg-do run }
// GROUPS passed virtual-functions
#include <stdio.h>
#include <stdlib.h>
int aset = 0;
class A
{
public:
void Set() { SetProp(); }
virtual void SetProp() { aset++;}
};
class B:public A
{
public:
void SetProp() { if (!aset) { printf ("FAIL\n"); exit (1);} aset--;}
};
int main()
{
A a;
B b;
A *c=new A;
A *d=new B;
a.Set();
b.Set();
c->Set();
d->Set();
printf ("PASS\n");
}
|