OSDN Git Service

2009-10-05 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / opt / anchor1.C
1 // { dg-do run }
2 // { dg-options "-O2" }
3
4 // The size of the construction vtable for YFont in YCoreFont was not
5 // updated to reflect its actual size.  On targets with section anchor
6 // support, the vtable for YCoreFont was laid out immediately after
7 // that, but the compiler thought it was about 40 bytes closer to the
8 // anchor than it actually was.
9
10 extern "C" void abort (void);
11
12 class refcounted {
13 public:
14     int __refcount;
15
16 public:
17     refcounted(): __refcount(0) {};
18     virtual ~refcounted() {}
19 };
20
21 class YFont : public virtual refcounted {
22 public:
23     virtual ~YFont() {}
24
25     virtual int ascent() const = 0;
26 };
27
28 struct XFontStruct {
29 };
30
31 class YCoreFont : public YFont {
32 public:
33     YCoreFont(char const * name);
34     virtual ~YCoreFont();
35
36     virtual int ascent() const { return 2; }
37
38 private:
39     XFontStruct * fFont;
40 };
41
42 YCoreFont::YCoreFont(char const * name) {
43 }
44
45 YCoreFont::~YCoreFont() {
46 }
47
48 int foo(YCoreFont *ycf)
49 {
50   return ycf->ascent ();
51 }
52
53 int main()
54 {
55   YCoreFont ycf("");
56   if (foo(&ycf) != 2)
57     abort ();
58   return 0;
59 }